Documentation ¶
Index ¶
- Variables
- func CompareHashAndPassword(ctx context.Context, hash, password string) error
- func GenerateFromPassword(ctx context.Context, password string) (string, error)
- func GenerateOtp(digits int) (string, error)
- func GenerateSignatures(secrets []string, msgID uuid.UUID, currentTime time.Time, inputPayload []byte) ([]string, error)
- func GenerateTokenHash(emailOrPhone, otp string) string
- func SecureToken(options ...int) string
- type HashCost
Constants ¶
This section is empty.
Variables ¶
View Source
var PasswordHashCost = DefaultHashCost
PasswordHashCost is the current pasword hashing cost for all new hashes generated with GenerateHashFromPassword.
Functions ¶
func CompareHashAndPassword ¶
CompareHashAndPassword compares the hash and password, returns nil if equal otherwise an error. Context can be used to cancel the hashing if the algorithm supports it.
func GenerateFromPassword ¶
GenerateFromPassword generates a password hash from a password, using PasswordHashCost. Context can be used to cancel the hashing if the algorithm supports it.
func GenerateOtp ¶
GenerateOtp generates a random n digit otp
func GenerateSignatures ¶
func GenerateTokenHash ¶
Types ¶
type HashCost ¶
type HashCost = int
const ( // DefaultHashCost represents the default // hashing cost for any hashing algorithm. DefaultHashCost HashCost = iota // QuickHashCosts represents the quickest // hashing cost for any hashing algorithm, // useful for tests only. QuickHashCost HashCost = iota // BCrypt hashed passwords have a 72 character limit MaxPasswordLength = 72 )
Click to show internal directories.
Click to hide internal directories.