Documentation
¶
Index ¶
- Constants
- func Crypt(keystr, saltstr string) string
- func GenerateSalt(length, rounds int) string
- func Hash64(src []byte) (hash []byte)
- func Verify(key, hash string) bool
- type Argon2idCredManager
- type BcryptCredManager
- type CredManager
- type Md5UserSaltCredManager
- type Pbkdf2SaltCredManager
- type PlainCredManager
- type Sha256SaltCredManager
- type Sha512CryptCredManager
- type Sha512SaltCredManager
Constants ¶
const ( MagicPrefix = "$6$" RandomSalt = "" RoundsDefault = 5000 RoundsMax = 999999999 RoundsMin = 1000 SaltLenMax = 16 SaltLenMin = 1 )
const Hash64Chars = "./0123456789" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz"
Variables ¶
This section is empty.
Functions ¶
func Crypt ¶ added in v1.0.7
Crypt takes key and salt strings and performs the SHA512-crypt hashing algorithm on them, returning a full hash string suitable for storage and later password verification.
If the salt string is the value RandomSalt, a randomly-generated salt parameter string will be generated with a length of SaltLenMax and RoundsDefault number of rounds.
func GenerateSalt ¶ added in v1.0.7
GenerateSalt creates a random salt parameter string with the random bytes being of the length provided, and the rounds parameter set as specified.
If the length is greater than SaltLenMax, a string of that length will be returned instead. Similarly, if length is less than SaltLenMin, a string of that length will be returned instead.
If rounds is equal to RoundsDefault, then the 'rounds=' part of the salt parameter string is elided.
func Hash64 ¶ added in v1.0.7
Hash64 is a variant of Base64 encoding. It is commonly used with password hashing algorithms to encode the result of their checksum output.
The algorithm operates on up to 3 bytes at a time, encoding the following 6-bit sequences into up to 4 hash64 ASCII bytes.
- Bottom 6 bits of the first byte
- Top 2 bits of the first byte, and bottom 4 bits of the second byte.
- Top 4 bits of the second byte, and bottom 2 bits of the third byte.
- Top 6 bits of the third byte.
This encoding method does not emit padding bytes as Base64 does.
Types ¶
type Argon2idCredManager ¶
type Argon2idCredManager struct{}
func NewArgon2idCredManager ¶
func NewArgon2idCredManager() *Argon2idCredManager
func (*Argon2idCredManager) GetHashedPassword ¶
func (cm *Argon2idCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*Argon2idCredManager) IsPasswordCorrect ¶
type BcryptCredManager ¶
type BcryptCredManager struct{}
func NewBcryptCredManager ¶
func NewBcryptCredManager() *BcryptCredManager
func (*BcryptCredManager) GetHashedPassword ¶
func (cm *BcryptCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*BcryptCredManager) IsPasswordCorrect ¶
type CredManager ¶
type CredManager interface { GetHashedPassword(password string, userSalt string, organizationSalt string) string IsPasswordCorrect(password string, passwordHash string, userSalt string, organizationSalt string) bool }
func GetCredManager ¶
func GetCredManager(passwordType string) CredManager
type Md5UserSaltCredManager ¶
type Md5UserSaltCredManager struct{}
func NewMd5UserSaltCredManager ¶
func NewMd5UserSaltCredManager() *Md5UserSaltCredManager
func (*Md5UserSaltCredManager) GetHashedPassword ¶
func (cm *Md5UserSaltCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*Md5UserSaltCredManager) IsPasswordCorrect ¶
type Pbkdf2SaltCredManager ¶
type Pbkdf2SaltCredManager struct{}
func NewPbkdf2SaltCredManager ¶
func NewPbkdf2SaltCredManager() *Pbkdf2SaltCredManager
func (*Pbkdf2SaltCredManager) GetHashedPassword ¶
func (cm *Pbkdf2SaltCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*Pbkdf2SaltCredManager) IsPasswordCorrect ¶
type PlainCredManager ¶
type PlainCredManager struct{}
func NewPlainCredManager ¶
func NewPlainCredManager() *PlainCredManager
func (*PlainCredManager) GetHashedPassword ¶
func (cm *PlainCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*PlainCredManager) IsPasswordCorrect ¶
type Sha256SaltCredManager ¶
type Sha256SaltCredManager struct{}
func NewSha256SaltCredManager ¶
func NewSha256SaltCredManager() *Sha256SaltCredManager
func (*Sha256SaltCredManager) GetHashedPassword ¶
func (cm *Sha256SaltCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*Sha256SaltCredManager) IsPasswordCorrect ¶
type Sha512CryptCredManager ¶ added in v1.0.7
type Sha512CryptCredManager struct{}
func NewSha512CryptCredManager ¶ added in v1.0.7
func NewSha512CryptCredManager() *Sha512CryptCredManager
func (*Sha512CryptCredManager) GetHashedPassword ¶ added in v1.0.7
func (cm *Sha512CryptCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string
func (*Sha512CryptCredManager) IsPasswordCorrect ¶ added in v1.0.7
type Sha512SaltCredManager ¶
type Sha512SaltCredManager struct{}
func NewSha512SaltCredManager ¶
func NewSha512SaltCredManager() *Sha512SaltCredManager
func (*Sha512SaltCredManager) GetHashedPassword ¶
func (cm *Sha512SaltCredManager) GetHashedPassword(password string, userSalt string, organizationSalt string) string