From bcc1c2d9dd7fefa538647c0d4e9e621511f1fde6 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 7 Oct 2025 08:31:39 -0700 Subject: Bring back pbkdf2 --- internal/pwhash/pwhash.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 internal/pwhash/pwhash.go (limited to 'internal/pwhash') diff --git a/internal/pwhash/pwhash.go b/internal/pwhash/pwhash.go new file mode 100644 index 0000000..576d052 --- /dev/null +++ b/internal/pwhash/pwhash.go @@ -0,0 +1,18 @@ +package pwhash + +import ( + "crypto/pbkdf2" + "crypto/sha512" +) + +const SaltSize = 8 + +const defaultIter = 12059332 // 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) +} -- cgit v1.3.1