summaryrefslogtreecommitdiffstats
path: root/tools/hashpw/hashpw.go
blob: 7705b31ca3cd7e29b96104fb2ad7fb4dc8191d98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main

import (
	"fmt"
	"os"

	"gitlab.com/rhogenson/roseh.moe/internal/cryptoutil"
	"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
	}
	hashedPassword, err := cryptoutil.Hash(string(password))
	if err != nil {
		return err
	}
	fmt.Printf("notepad-password=%s\n", hashedPassword)
	return nil
}

func main() {
	if err := run(); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}