Documentation
¶
Overview ¶
Package md5 implements the MD5 hashing algorithm for crypt(3).
Index ¶
Examples ¶
Constants ¶
View Source
const ( MaxSaltLength = 8 DefaultSaltLength = MaxSaltLength )
View Source
const Prefix = "$1$"
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check compares the given crypt(3) MD5 hash with a new hash derived from the password. Returns nil on success, or an error on failure.
Example ¶
package main import ( "fmt" "github.com/sergeymakinen/go-crypt/md5" ) func main() { hash := "$1$ip0xp41O$7DHwMihQRmDjn2tiJ17mw." fmt.Println(md5.Check(hash, "password")) fmt.Println(md5.Check(hash, "test")) }
Output: <nil> hash and password mismatch
func Key ¶
Key returns a MD5 key derived from the password and salt.
Example ¶
package main import ( "fmt" "github.com/sergeymakinen/go-crypt/hash" "github.com/sergeymakinen/go-crypt/md5" ) func main() { salt, _ := md5.Salt("$1$ip0xp41O$7DHwMihQRmDjn2tiJ17mw.") fmt.Println(string(salt)) key, _ := md5.Key([]byte("password"), salt) fmt.Println(hash.LittleEndianEncoding.EncodeToString(key)) }
Output: ip0xp41O 7DHwMihQRmDjn2tiJ17mw.
Types ¶
type InvalidSaltError ¶
type InvalidSaltError byte
InvalidSaltError values describe errors resulting from an invalid character in a hash string.
func (InvalidSaltError) Error ¶
func (e InvalidSaltError) Error() string
type InvalidSaltLengthError ¶
type InvalidSaltLengthError int
InvalidSaltLengthError values describe errors resulting from an invalid length of a salt.
func (InvalidSaltLengthError) Error ¶
func (e InvalidSaltLengthError) Error() string
type UnsupportedPrefixError ¶
type UnsupportedPrefixError string
UnsupportedPrefixError values describe errors resulting from an unsupported prefix string.
func (UnsupportedPrefixError) Error ¶
func (e UnsupportedPrefixError) Error() string
Click to show internal directories.
Click to hide internal directories.