summaryrefslogtreecommitdiffstats
path: root/internal/pwhash/pwhash.go
blob: 22b53687309fb43a590eb28d2c3c1cfda59519d9 (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 = 12500992 // 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)
}