Documentation ¶
Overview ¶
Package des implements the DES hashing algorithm for crypt(3).
Index ¶
Examples ¶
Constants ¶
View Source
const MaxPasswordLength = 8
View Source
const Prefix = ""
View Source
const SaltLength = 2
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check compares the given crypt(3) DES 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/des" ) func main() { hash := "eNBO0nZMf3rWM" fmt.Println(des.Check(hash, "password")) fmt.Println(des.Check(hash, "test")) }
Output: <nil> hash and password mismatch
func Key ¶
Key returns a DES key derived from the password and salt.
Example ¶
package main import ( "fmt" "github.com/sergeymakinen/go-crypt/des" "github.com/sergeymakinen/go-crypt/hash" ) func main() { salt, _ := des.Salt("eNBO0nZMf3rWM") fmt.Println(string(salt)) key, _ := des.Key([]byte("password"), salt) fmt.Println(hash.BigEndianEncoding.EncodeToString(key)) }
Output: eN BO0nZMf3rWM
Types ¶
type InvalidPasswordLengthError ¶
type InvalidPasswordLengthError int
InvalidPasswordLengthError values describe errors resulting from an invalid length of a password.
func (InvalidPasswordLengthError) Error ¶
func (e InvalidPasswordLengthError) Error() string
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.