diff options
Diffstat (limited to 'tools/hashpw')
| -rw-r--r-- | tools/hashpw/hashpw.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go new file mode 100644 index 0000000..5bc740d --- /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 run() error { + fmt.Print("Enter password:") + password, err := term.ReadPassword(int(os.Stdin.Fd())) + fmt.Println() + if err != nil { + return err + } + salt := make([]byte, pwhash.SaltLen) + rand.Read(salt) + _, hashedPassword, err := pwhash.Hash(string(password), salt) + if err != nil { + return err + } + fmt.Printf("notepad-password=%x%x\n", salt, hashedPassword) + return nil +} + +func main() { + if err := run(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} |
