package pwhash import ( "crypto/pbkdf2" "crypto/sha256" "crypto/sha512" ) const defaultIterations = 3670016 // from cmd/finditers func HashIter(password string, salt []byte, iter int) ([]byte, error) { return pbkdf2.Key(sha256.New, password, salt, iter, 32) } func Hash(password string, salt []byte) ([]byte, error) { hashed, err := HashIter(password, salt, defaultIterations) if err != nil { return nil, err } sha := sha512.Sum512(hashed) return sha[:], nil }