summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/finditer/finditer.go43
-rw-r--r--tools/hashpw/hashpw.go46
2 files changed, 0 insertions, 89 deletions
diff --git a/tools/finditer/finditer.go b/tools/finditer/finditer.go
deleted file mode 100644
index 114785d..0000000
--- a/tools/finditer/finditer.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package main
-
-import (
- "encoding/hex"
- "fmt"
- "sort"
- "testing"
- "time"
-
- "roseh.moe/pkg/roseh.moe/internal/pwhash"
-)
-
-func mustHex(s string) []byte {
- b, err := hex.DecodeString(s)
- if err != nil {
- panic(err)
- }
- return b
-}
-
-const password = "emcee polio cardiac disclose superglue clapper cruelness stonework tingly unarmored"
-
-var salt = mustHex("a0aa6971f38827e5")
-
-var iterations int
-
-func BenchmarkHashIter(b *testing.B) {
- for b.Loop() {
- pwhash.HashIter(password, salt, iterations)
- }
-}
-
-func main() {
- const targetDuration = 5 * time.Second
- for iterations = 8192; 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 f1e76db..0000000
--- a/tools/hashpw/hashpw.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package main
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/base64"
- "fmt"
- "os"
- "slices"
-
- "golang.org/x/term"
- "roseh.moe/pkg/roseh.moe/internal/pwhash"
-)
-
-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
- }
- fmt.Fprint(os.Stderr, "Confirm password: ")
- pwConfirm, err := term.ReadPassword(int(os.Stdin.Fd()))
- fmt.Fprintln(os.Stderr)
- if err != nil {
- return err
- }
- if !bytes.Equal(password, pwConfirm) {
- return fmt.Errorf("passwords do not match")
- }
- salt := make([]byte, pwhash.SaltSize)
- rand.Read(salt)
- hash, err := pwhash.Hash(string(password), salt)
- if err != nil {
- return err
- }
- fmt.Printf("NotepadPassword:%q\n", base64.StdEncoding.EncodeToString(slices.Concat(hash, salt)))
- return nil
-}
-
-func main() {
- if err := hashpw(); err != nil {
- fmt.Fprintln(os.Stderr, err)
- os.Exit(1)
- }
-}