Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomSalt ¶
func GenerateRandomSalt() []byte
GenerateRandomSalt helper function to generate a random salt
func GenerateRandomSalts ¶
GenerateRandomSalt helper function to generate a random salt with the specified salt size
func IsAlgorithmAllowed ¶
func IsAlgorithmAllowed(algorithm HashAlgorithm) bool
Types ¶
type HashAlgorithm ¶
type HashAlgorithm string
Defined type for hashing algorithm
const ( // Hash algorithms BCrypt HashAlgorithm = "bcrypt" SHA256 HashAlgorithm = "sha256" // Default salt size DefaultSaltSize = 16 )
type PasswordHasher ¶
type PasswordHasher interface { GenerateHashPassword(password []byte, salt []byte) ([]byte, error) VerifyPassword(hashedPassword []byte, password []byte, salt []byte) (bool, error) }
PasswordHasher is the interface for password hasing
type PasswordHasherImpl ¶
type PasswordHasherImpl struct {
// contains filtered or unexported fields
}
PasswordHasher is the implementation of the PasswordHasher interface
func New ¶
func New(algorithm HashAlgorithm) *PasswordHasherImpl
New create an object of the PasswordHasherImpl
func (PasswordHasherImpl) GenerateHashPassword ¶
func (h PasswordHasherImpl) GenerateHashPassword(password []byte, salt []byte) ([]byte, error)
GenerateHashPassword generate hashed password with the given salt
func (PasswordHasherImpl) VerifyPassword ¶
func (h PasswordHasherImpl) VerifyPassword(hashedPassword []byte, password []byte, salt []byte) (bool, error)
VerifyPassword compare hashed password with the clear password and given salt
Click to show internal directories.
Click to hide internal directories.