diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-05 21:58:44 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-05 21:58:44 -0700 |
| commit | bcbb629db87b6bc0e9a7880ec4ee1c90d284a6c7 (patch) | |
| tree | 7372c59802fb589f798a9e849d621dac158dc04b /tools/hashpw/hashpw.go | |
| parent | Games first (diff) | |
| download | roseh.moe-bcbb629db87b6bc0e9a7880ec4ee1c90d284a6c7.tar.zst | |
Bring back the notepad
Diffstat (limited to 'tools/hashpw/hashpw.go')
| -rw-r--r-- | tools/hashpw/hashpw.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go new file mode 100644 index 0000000..c668622 --- /dev/null +++ b/tools/hashpw/hashpw.go @@ -0,0 +1,32 @@ +package main + +import ( + "encoding/base64" + "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 + } + hash, err := pwhash.Hash(string(password)) + if err != nil { + return err + } + fmt.Printf("notepad-password=%s\n", base64.RawURLEncoding.EncodeToString(hash)) + return nil +} + +func main() { + if err := hashpw(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} |
