diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/finditers/finditers.go | 42 | ||||
| -rw-r--r-- | tools/hashpw/hashpw.go | 32 | ||||
| -rw-r--r-- | tools/secret-key/secret-key.go | 14 |
3 files changed, 0 insertions, 88 deletions
diff --git a/tools/finditers/finditers.go b/tools/finditers/finditers.go deleted file mode 100644 index 31a7e33..0000000 --- a/tools/finditers/finditers.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "encoding/hex" - "fmt" - "sort" - "testing" - "time" - - "gitlab.com/rhogenson/roseh.moe/internal/pwhash" -) - -func mustHex(t testing.TB, s string) []byte { - t.Helper() - b, err := hex.DecodeString(s) - if err != nil { - t.Fatalf("Invalid hex %q: %s", s, err) - } - return b -} - -var iterations int - -func BenchmarkHashIter(b *testing.B) { - const pw = "atypical evasion foyer roulette throng awning stability exchange humorless vowed" - salt := mustHex(b, "4250af599e07cde7") - for b.Loop() { - pwhash.HashIter(pw, salt, iterations) - } -} - -func main() { - const targetDuration = 5 * time.Second - for iterations = 4096; time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) < targetDuration; iterations *= 2 { - } - lo := iterations / 2 - hi := iterations - fmt.Println(lo + sort.Search(hi-lo, func(i int) bool { - iterations = lo + i - return time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) > targetDuration - })) -} diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go deleted file mode 100644 index c668622..0000000 --- a/tools/hashpw/hashpw.go +++ /dev/null @@ -1,32 +0,0 @@ -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) - } -} diff --git a/tools/secret-key/secret-key.go b/tools/secret-key/secret-key.go deleted file mode 100644 index 969828a..0000000 --- a/tools/secret-key/secret-key.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "crypto/rand" - "crypto/sha256" - "encoding/base64" - "fmt" -) - -func main() { - buf := make([]byte, sha256.BlockSize) - rand.Read(buf) - fmt.Printf("secret-key=%s\n", base64.RawURLEncoding.EncodeToString(buf)) -} |
