Documentation ¶
Overview ¶
Package lib provides additional functionalities to the application:
- AES encryption-decryption - Argon2id hashing - SHA hashing - Two-factor authentication - Email format validation along with MX lookup
Index ¶
- func ByteToPNG(imgByte []byte, path string) (string, error)
- func Decrypt(ciphertext []byte, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte) ([]byte, error)
- func FileExist(path string) bool
- func HTMLModel(in []string) map[string]interface{}
- func HashPass(config HashPassConfig, pass, secret string) (string, error)
- func InitRateLimiter(formattedRateLimit, trustedPlatform string) (*limiter.Limiter, error)
- func NewQR(encryptedMessage []byte, issuer string) ([]byte, error)
- func NewTOTP(account string, issuer string, hash crypto.Hash, digits int) ([]byte, error)
- func RemoveAllSpace(s string) string
- func SecureRandomNumber(totalDigit uint64) uint64
- func StrArrHTMLModel(s string) []string
- func ValidateEmail(e string) bool
- func ValidateTOTP(encryptedMessage []byte, issuer string, userInput string) ([]byte, error)
- type HashPassConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶ added in v1.6.1
Decrypt using AES algorithm AES128 key size: 16 bytes AES192 key size: 24 bytes AES256 key size: 32 bytes
func Encrypt ¶ added in v1.6.1
Encrypt using AES algorithm
- AES128 key size: 16 bytes - AES192 key size: 24 bytes - AES256 key size: 32 bytes
func HTMLModel ¶ added in v1.6.1
HTMLModel takes a slice and builds a model for populating a templated email
func HashPass ¶
func HashPass(config HashPassConfig, pass, secret string) (string, error)
HashPass - securely hash passwords using Argon2id
func InitRateLimiter ¶ added in v1.6.27
InitRateLimiter - initialize the rate limiter instance
func NewQR ¶ added in v1.6.1
NewQR - creates a byte array containing QR code encoded PNG image, with level Q error correction, needed for the client apps to generate tokens.
func NewTOTP ¶ added in v1.6.1
NewTOTP - creates a new TOTP object and returns a serialized byte array
func RemoveAllSpace ¶
RemoveAllSpace - remove all spaces and return the result as string
func SecureRandomNumber ¶ added in v1.6.1
SecureRandomNumber generates cryptographically secure pseudo-random number. To generate a random number consisting of x number of digits, pass x as the parameter. For example, SecureRandomNumber(3) will generate a number between 100 and 999
func StrArrHTMLModel ¶ added in v1.6.1
StrArrHTMLModel first slices a string into all substrings separated by `;` and then slices each substring separated by `:` for `HTMLModel` function
Example: StrArrHTMLModel(key1:value1,key2:value2,key3:value3) will return [key1 value1 key2 value2 key3 value3]
func ValidateEmail ¶
ValidateEmail - check if the email provided passes the required structure and length test. It also checks the domain has a valid MX record.
Credit: Edd Turtle
Types ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package middleware contains:
|
Package middleware contains: |
Package renderer uses template engine to render and serve HTML pages
|
Package renderer uses template engine to render and serve HTML pages |