diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/finditers/finditers.go | 14 | ||||
| -rw-r--r-- | tools/hashpw/hashpw.go | 9 |
2 files changed, 14 insertions, 9 deletions
diff --git a/tools/finditers/finditers.go b/tools/finditers/finditers.go index 2a256c8..cd144fa 100644 --- a/tools/finditers/finditers.go +++ b/tools/finditers/finditers.go @@ -8,19 +8,27 @@ import ( "testing" "time" - "gitlab.com/rhogenson/roseh.moe/internal/pwhash" + "gitlab.com/rhogenson/roseh.moe/internal/cryptoutil" ) +func mustHex(s string) []byte { + bytes, err := hex.DecodeString(s) + if err != nil { + panic(fmt.Sprintf("mustHex: bad hex %q: %s", s, err)) + } + return bytes +} + var ( iterations int - salt, _ = hex.DecodeString("3fb84513fc3afcd6d3b230bf9ece91aaae2d2a99da17efbf7de83b21fafe3f08") + salt = mustHex("3fb84513fc3afcd6d3b230bf9ece91aaae2d2a99da17efbf7de83b21fafe3f08") ) func BenchmarkHashIter(b *testing.B) { const password = "oboe shortness ether ideology undesired fresh freezable catching mashing glimpse" for b.Loop() { - pwhash.HashIter(password, salt, iterations) + cryptoutil.HashIter(password, salt, iterations) } } diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go index 5bc740d..7705b31 100644 --- a/tools/hashpw/hashpw.go +++ b/tools/hashpw/hashpw.go @@ -1,11 +1,10 @@ package main import ( - "crypto/rand" "fmt" "os" - "gitlab.com/rhogenson/roseh.moe/internal/pwhash" + "gitlab.com/rhogenson/roseh.moe/internal/cryptoutil" "golang.org/x/term" ) @@ -16,13 +15,11 @@ func run() error { if err != nil { return err } - salt := make([]byte, pwhash.SaltLen) - rand.Read(salt) - _, hashedPassword, err := pwhash.Hash(string(password), salt) + hashedPassword, err := cryptoutil.Hash(string(password)) if err != nil { return err } - fmt.Printf("notepad-password=%x%x\n", salt, hashedPassword) + fmt.Printf("notepad-password=%s\n", hashedPassword) return nil } |
