package pwhash import ( "crypto/pbkdf2" "crypto/sha512" ) const SaltLen = sha512.Size const defaultIterations = 903636 // from cmd/finditers func HashIter(password string, salt []byte, iter int) ([]byte, error) { return pbkdf2.Key(sha512.New, password, salt, iter, sha512.Size) } func Hash(password string, salt []byte) (key, pwHash []byte, err error) { const aesKeySize = 32 key, err = HashIter(password, salt, defaultIterations) if err != nil { return nil, nil, err } return key[:aesKeySize], key[aesKeySize:], nil }