diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-21 18:44:58 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-21 18:44:58 -0800 |
| commit | 0d640e791493de79b43b050a13b1cf9c081854ec (patch) | |
| tree | e545cc0db40612260c8a1995d38f6bb600a87c2f /tools/finditer | |
| parent | 4be64dd369b4bbdf3c4c0972c949c6e150377699 (diff) | |
| download | roseh.moe-0d640e791493de79b43b050a13b1cf9c081854ec.tar.zst | |
Simplify the password hash and get rid of pbkdf2
Since the password already has 16 bytes of security, pbkdf2 isn't
necessary here. We can use a simple sha256. I promise to pick a
secure password.
Diffstat (limited to 'tools/finditer')
| -rw-r--r-- | tools/finditer/finditer.go | 43 |
1 files changed, 0 insertions, 43 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 - })) -} |
