Documentation
¶
Index ¶
- Constants
- func AToI64(c byte) (val int)
- func Base64Append(dst []byte, v uint, n int) []byte
- func Base64Encode(src []byte) []byte
- func Base64RotateEncode(src []byte, order bool) []byte
- func Base64Uint32Decode(src []byte, dstbits uint32) (dst uint32)
- func Base64Uint32Encode(src, srcbits uint32) (b64 []byte)
- func CheckPassword(hash []byte, password []byte) (bool, error)
- func HashBlockRecycle(h hash.Hash, block []byte, len int)
- func HashGostYesCryptPassword(password []byte) (hash []byte, err error)
- func HashGostYesCryptPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashMD5Password(password []byte) (hash []byte, err error)
- func HashMD5PasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashNTPassword(password []byte) (hash []byte, err error)
- func HashNTPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashSCryptPassword(password []byte) (hash []byte, err error)
- func HashSCryptPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashSHA1Password(password []byte) (hash []byte, err error)
- func HashSHA1PasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashSHA256Password(password []byte) (hash []byte, err error)
- func HashSHA256PasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashSHA512Password(password []byte) (hash []byte, err error)
- func HashSHA512PasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashSunMD5Password(password []byte) (hash []byte, err error)
- func HashSunMD5PasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func HashYesCryptPassword(password []byte) (hash []byte, err error)
- func HashYesCryptPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func IToA64(N int) (val byte, err error)
- func MD5Base64Encode(src []byte) []byte
- func N2log2(N uint64) (N_log2 int)
- func SCheckPassword(hash string, password string) (bool, error)
- func SCryptBase64Decode(src []byte) []byte
- func SCryptBase64Encode(src []byte) []byte
- func SHashGostYesCryptPassword(password string) (hash string, err error)
- func SHashGostYesCryptPasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashMD5Password(password string) (hash string, err error)
- func SHashMD5PasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashNTPassword(password string) (hash string, err error)
- func SHashNTPasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashSCryptPassword(password string) (hash string, err error)
- func SHashSCryptPasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashSHA1Password(password string) (hash string, err error)
- func SHashSHA1PasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashSHA256Password(password string) (hash string, err error)
- func SHashSHA256PasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashSHA512Password(password string) (hash string, err error)
- func SHashSHA512PasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashSunMD5Password(password string) (hash string, err error)
- func SHashSunMD5PasswordWithSalt(password string, salt string) (hash string, err error)
- func SHashYesCryptPassword(password string) (hash string, err error)
- func SHashYesCryptPasswordWithSalt(password string, salt string) (hash string, err error)
- type GostYesCrypt
- type MD5Crypt
- type NTHash
- type Passwd
- func (a *Passwd) GenerateSalt() ([]byte, error)
- func (a *Passwd) HashPassword(password []byte) (hash []byte, err error)
- func (a *Passwd) HashPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
- func (a *Passwd) SHashPassword(password string) (hash string, err error)
- func (a *Passwd) SHashPasswordWithSalt(password string, salt string) (hash string, err error)
- func (a *Passwd) SetParams(p string)
- func (a *Passwd) SetSalt(s []byte)
- type PasswdInterface
- func NewGostYesCryptPasswd() PasswdInterface
- func NewMD5CryptPasswd() PasswdInterface
- func NewNTPasswd() PasswdInterface
- func NewPasswd(settings string) (PasswdInterface, error)
- func NewSCryptPasswd() PasswdInterface
- func NewSHA1Passwd() PasswdInterface
- func NewSHA256CryptPasswd() PasswdInterface
- func NewSHA512CryptPasswd() PasswdInterface
- func NewSunMD5Passwd() PasswdInterface
- func NewYesCryptPasswd() PasswdInterface
- type SCrypt
- type SHA1Crypt
- type SHA256Crypt
- type SHA512Crypt
- type SunMD5
- type YesCrypt
Constants ¶
const ( SHA1_CRYPT_MAGIC = "$sha1$" SHA1_SIZE = 20 SUN_MD5_MAGIC = "$md5" MD5_CRYPT_MAGIC = "$1$" MD5_SIZE = 16 NT_HASH_MAGIC = "$3$" MD4_SIZE = 16 SHA256_CRYPT_MAGIC = "$5$" SHA256_SIZE = 32 SHA512_CRYPT_MAGIC = "$6$" SHA512_SIZE = 64 S_CRYPT_MAGIC = "$7$" YES_CRYPT_MAGIC = "$y$" GOST_YES_CRYPT_MAGIC = "$gy$" )
Variables ¶
This section is empty.
Functions ¶
func Base64Append ¶
Append base64 for provided uint.
func Base64RotateEncode ¶
The crypt standard likes to rotate bits in base64, although it doesn't really do anything for brute force protection. This performs the rotation algorithm.
func Base64Uint32Decode ¶
Decode uint32 from base64 at a fixed length.
func Base64Uint32Encode ¶
Encode uint32 into base64 at a fixed length.
func CheckPassword ¶
Check a password hash against a password.
func HashBlockRecycle ¶
Takes a prior hash, and recycles bytes until the length provided is covered.
func HashGostYesCryptPassword ¶
Hash an password using default parameters with Gost Yes Crypt.
func HashGostYesCryptPasswordWithSalt ¶
Hash an password with salt using default parameters with Gost Yes Crypt.
func HashMD5Password ¶
Hash an password using default parameters with MD5.
func HashMD5PasswordWithSalt ¶
Hash an password with salt using default parameters with MD5.
func HashNTPassword ¶
Hash an password using default parameters with NT.
func HashNTPasswordWithSalt ¶
Hash an password with salt using default parameters with NT.
func HashSCryptPassword ¶
Hash an password using default parameters with SCrypt.
func HashSCryptPasswordWithSalt ¶
Hash an password with salt using default parameters with SCrypt.
func HashSHA1Password ¶
Hash an password using default parameters with SHA1.
func HashSHA1PasswordWithSalt ¶
Hash an password with salt using default parameters with SHA1.
func HashSHA256Password ¶
Hash an password using default parameters with SHA256.
func HashSHA256PasswordWithSalt ¶
Hash an password with salt using default parameters with SHA256.
func HashSHA512Password ¶
Hash an password using default parameters with SHA512.
func HashSHA512PasswordWithSalt ¶
Hash an password with salt using default parameters with SHA512.
func HashSunMD5Password ¶
Hash an password using default parameters with Sun MD5.
func HashSunMD5PasswordWithSalt ¶
Hash an password with salt using default parameters with Sun MD5.
func HashYesCryptPassword ¶
Hash an password using default parameters with YesCrypt.
func HashYesCryptPasswordWithSalt ¶
Hash an password with salt using default parameters with YesCrypt.
func MD5Base64Encode ¶
Encode MD5 result to MD5 crypt base64.
func SCheckPassword ¶
Check a password hash against a password string.
func SCryptBase64Decode ¶
Decode base64 in the format used for SCrypt hashes.
func SCryptBase64Encode ¶
Encode base64 in the format used for SCrypt hashes.
func SHashGostYesCryptPassword ¶
Hash an password string using default parameters with Gost Yes Crypt.
func SHashGostYesCryptPasswordWithSalt ¶
Hash an password string with salt using default parameters with Gost Yes Crypt.
func SHashMD5Password ¶
Hash an password string using default parameters with MD5.
func SHashMD5PasswordWithSalt ¶
Hash an password string with salt using default parameters with MD5.
func SHashNTPassword ¶
Hash an password string using default parameters with NT.
func SHashNTPasswordWithSalt ¶
Hash an password string with salt using default parameters with NT.
func SHashSCryptPassword ¶
Hash an password string using default parameters with SCrypt.
func SHashSCryptPasswordWithSalt ¶
Hash an password string with salt using default parameters with SCrypt.
func SHashSHA1Password ¶
Hash an password string using default parameters with SHA1.
func SHashSHA1PasswordWithSalt ¶
Hash an password string with salt using default parameters with SHA1.
func SHashSHA256Password ¶
Hash an password string using default parameters with SHA256.
func SHashSHA256PasswordWithSalt ¶
Hash an password string with salt using default parameters with SHA256.
func SHashSHA512Password ¶
Hash an password string using default parameters with SHA512.
func SHashSHA512PasswordWithSalt ¶
Hash an password string with salt using default parameters with SHA512.
func SHashSunMD5Password ¶
Hash an password string using default parameters with Sun MD5.
func SHashSunMD5PasswordWithSalt ¶
Hash an password string with salt using default parameters with Sun MD5.
func SHashYesCryptPassword ¶
Hash an password string using default parameters with YesCrypt.
Types ¶
type GostYesCrypt ¶
type GostYesCrypt struct {
Passwd
}
func (*GostYesCrypt) DecodeSCryptParams ¶
func (a *GostYesCrypt) DecodeSCryptParams() (N, r int)
Decode SCrypt params.
func (*GostYesCrypt) Hash ¶
func (a *GostYesCrypt) Hash(password []byte, salt []byte) (hash []byte, err error)
Hash a password with salt using gost yes crypt standard.
func (*GostYesCrypt) HashPasswordWithSalt ¶
func (a *GostYesCrypt) HashPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
Override the passwd hash with salt function to hash with gost yes crypt.
func (*GostYesCrypt) SetSCryptParams ¶
func (a *GostYesCrypt) SetSCryptParams(N, r int) (err error)
Sets the SCrypt params using integers.
type MD5Crypt ¶
type MD5Crypt struct {
Passwd
}
type NTHash ¶
type NTHash struct {
Passwd
}
func (*NTHash) HashPasswordWithSalt ¶
Override the hash with salt function with one that encodes the NT hash, ignoring the salt.
func (*NTHash) UTF8ToUCS2LE ¶
Encode UTF-8 bytes to UCS-2LE bytes. The NT hash uses UCS-2LE, so we need to convert for compatibility.
type Passwd ¶
type Passwd struct { Magic string Params string SaltLength int Salt []byte // contains filtered or unexported fields }
Base structure.
func (*Passwd) GenerateSalt ¶
Generate a salt based on configs for this paassword algorithm.
func (*Passwd) HashPassword ¶
Hash a password.
func (*Passwd) HashPasswordWithSalt ¶
Hash a password with a custom salt.
func (*Passwd) SHashPassword ¶
Hash a password string.
func (*Passwd) SHashPasswordWithSalt ¶
Hash a password string with a custom salt.
type PasswdInterface ¶
type PasswdInterface interface { SetParams(p string) SetSalt(s []byte) GenerateSalt() ([]byte, error) HashPassword(password []byte) (hash []byte, err error) HashPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error) SHashPassword(password string) (hash string, err error) SHashPasswordWithSalt(password string, salt string) (hash string, err error) }
Standard protocol for working with all hash algorithms.
func NewGostYesCryptPasswd ¶
func NewGostYesCryptPasswd() PasswdInterface
Make an MD5Crypt password instance.
func NewMD5CryptPasswd ¶
func NewMD5CryptPasswd() PasswdInterface
Make an MD5Crypt password instance.
func NewPasswd ¶
func NewPasswd(settings string) (PasswdInterface, error)
Get a password interface based on hash settings string.
func NewSHA1Passwd ¶
func NewSHA1Passwd() PasswdInterface
func NewSHA256CryptPasswd ¶
func NewSHA256CryptPasswd() PasswdInterface
Make an MD5Crypt password instance.
func NewSHA512CryptPasswd ¶
func NewSHA512CryptPasswd() PasswdInterface
Make an MD5Crypt password instance.
func NewYesCryptPasswd ¶
func NewYesCryptPasswd() PasswdInterface
Make an MD5Crypt password instance.
type SCrypt ¶
type SCrypt struct {
Passwd
}
func (*SCrypt) DecodeSCryptParams ¶
Decode SCrypt params.
func (*SCrypt) HashPasswordWithSalt ¶
Override the passwd hash with salt function to hash with scrypt.
func (*SCrypt) SetSCryptParams ¶
Sets the SCrypt params using integers.
type SHA1Crypt ¶
type SHA1Crypt struct {
Passwd
}
type SHA256Crypt ¶
type SHA256Crypt struct {
Passwd
}
func (*SHA256Crypt) Hash ¶
func (a *SHA256Crypt) Hash(password []byte, salt []byte, iterations uint64) (hash []byte)
Hash a password with salt using SHA256 crypt standard.
func (*SHA256Crypt) HashPasswordWithSalt ¶
func (a *SHA256Crypt) HashPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
Override the passwd hash with salt function to hash with SHA256 crypt.
type SHA512Crypt ¶
type SHA512Crypt struct {
Passwd
}
func (*SHA512Crypt) Hash ¶
func (a *SHA512Crypt) Hash(password []byte, salt []byte, iterations uint64) (hash []byte)
Hash a password with salt using SHA512 crypt standard.
func (*SHA512Crypt) HashPasswordWithSalt ¶
func (a *SHA512Crypt) HashPasswordWithSalt(password []byte, salt []byte) (hash []byte, err error)
Override the passwd hash with salt function to hash with SHA512 crypt.
type SunMD5 ¶
type SunMD5 struct {
Passwd
}
func (*SunMD5) HashPasswordWithSalt ¶
Override the passwd hash with salt function to hash with Sun MD5.
type YesCrypt ¶
type YesCrypt struct {
Passwd
}
func (*YesCrypt) DecodeSCryptParams ¶
Decode SCrypt params.
func (*YesCrypt) HashPasswordWithSalt ¶
Override the passwd hash with salt function to hash with yes crypt.
func (*YesCrypt) SetSCryptParams ¶
Sets the SCrypt params using integers.