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 --- tools/hashpw/hashpw.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/hashpw/hashpw.go (limited to 'tools/hashpw/hashpw.go') diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go new file mode 100644 index 0000000..c75fa2e --- /dev/null +++ b/tools/hashpw/hashpw.go @@ -0,0 +1,34 @@ +package main + +import ( + "crypto/rand" + "fmt" + "os" + + "gitlab.com/rhogenson/roseh.moe/internal/pwhash" + "golang.org/x/term" +) + +func hashpw() error { + fmt.Fprint(os.Stderr, "Enter password: ") + password, err := term.ReadPassword(int(os.Stdin.Fd())) + fmt.Fprintln(os.Stderr) + if err != nil { + return err + } + salt := make([]byte, pwhash.SaltSize) + rand.Read(salt) + hash, err := pwhash.Hash(string(password), salt) + if err != nil { + return err + } + fmt.Printf("%x%x\n", hash, salt) + return nil +} + +func main() { + if err := hashpw(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} -- cgit v1.3.1