summaryrefslogtreecommitdiffstats
path: root/internal/pwhash/pwhash.go
blob: d8a1b3365cdc57bffe9fc7476fd6e4f4c5a6b532 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package pwhash

import (
	"crypto/pbkdf2"
	"crypto/sha512"
)

const SaltSize = 8

const defaultIter = 12175430 // from tools/finditer

func HashIter(password string, salt []byte, iter int) ([]byte, error) {
	return pbkdf2.Key(sha512.New, password, salt, iter, 32)
}

func Hash(password string, salt []byte) ([]byte, error) {
	return HashIter(password, salt, defaultIter)
}