Documentation ¶
Index ¶
- Constants
- func ComparePassword(hashedPassword, password string) (match bool, err error)
- func ExtractClaims(tokenString string, tokenSecretKey string) (jwt.MapClaims, error)
- func ExtractToken(bearer string) (token string, err error)
- func GenerateJWT(m map[string]interface{}, tokenExpireTime time.Duration, tokenSecretKey string) (tokenString string, err error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomCode(n int) (string, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateRandomStringByPool(n int, pool string) (string, error)
- func HashPassword(password string) (hashedPassword string, err error)
- type TokenInfo
Constants ¶
const ( // A2IDtime is the number of iterations (or passes) over the memory used by the algorithm Argon2id A2IDtime = 3 // A2IDmemory is the amount of memory used by the algorithm Argon2id A2IDmemory = 64 * 1024 // A2IDthreads is the number of threads used by the algorithm Argon2id A2IDthreads = 4 // A2IDkeyLen is the length of the generated key (or password hash) by the algorithm Argon2id. 16 bytes or more is recommended. A2IDkeyLen = 32 // A2IDsaltLen is the length of the random salt used by the algorithm Argon2id. 16 bytes is recommended for password hashing. A2IDsaltLen = 16 )
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword is used to compare a user-inputted password to a hash to see if the password matches or not.
func ExtractClaims ¶
ExtractClaims extracts claims from given token
func ExtractToken ¶
ExtractToken checks and returns token part of input string
func GenerateJWT ¶
func GenerateJWT(m map[string]interface{}, tokenExpireTime time.Duration, tokenSecretKey string) (tokenString string, err error)
GenerateJWT ...
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes
func GenerateRandomCode ¶
GenerateRandomCode returns a securely generated random string that consists of numbers that has length of 2*n
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string.
func GenerateRandomStringByPool ¶
GenerateRandomStringByPool returns a securely generated random string based on pool.
func HashPassword ¶
HashPassword is used to generate a new password hash for storing and comparing at a later date.