From 0d640e791493de79b43b050a13b1cf9c081854ec Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 21 Nov 2025 18:44:58 -0800 Subject: Simplify the password hash and get rid of pbkdf2 Since the password already has 16 bytes of security, pbkdf2 isn't necessary here. We can use a simple sha256. I promise to pick a secure password. --- tools/hashpw/hashpw.go | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 tools/hashpw/hashpw.go (limited to 'tools/hashpw/hashpw.go') diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go deleted file mode 100644 index f1e76db..0000000 --- a/tools/hashpw/hashpw.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "bytes" - "crypto/rand" - "encoding/base64" - "fmt" - "os" - "slices" - - "golang.org/x/term" - "roseh.moe/pkg/roseh.moe/internal/pwhash" -) - -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 - } - fmt.Fprint(os.Stderr, "Confirm password: ") - pwConfirm, err := term.ReadPassword(int(os.Stdin.Fd())) - fmt.Fprintln(os.Stderr) - if err != nil { - return err - } - if !bytes.Equal(password, pwConfirm) { - return fmt.Errorf("passwords do not match") - } - salt := make([]byte, pwhash.SaltSize) - rand.Read(salt) - hash, err := pwhash.Hash(string(password), salt) - if err != nil { - return err - } - fmt.Printf("NotepadPassword:%q\n", base64.StdEncoding.EncodeToString(slices.Concat(hash, salt))) - return nil -} - -func main() { - if err := hashpw(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} -- cgit v1.3.1