From d89b325294201d95498ae9d08f102e12ac2f2876 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 5 Oct 2025 18:00:06 -0700 Subject: Implement a "magic wormhole" file-sharing solution --- tools/finditers/finditers.go | 53 -------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 tools/finditers/finditers.go (limited to 'tools/finditers/finditers.go') diff --git a/tools/finditers/finditers.go b/tools/finditers/finditers.go deleted file mode 100644 index 746242b..0000000 --- a/tools/finditers/finditers.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "fmt" - "math/rand/v2" - "os" - "sort" - "testing" - "time" - - "gitlab.com/rhogenson/roseh.moe/internal/cryptoutil" -) - -var ( - iterations int - - salt = func() []byte { - r := rand.New(new(rand.PCG)) - salt := make([]byte, cryptoutil.SaltSize) - for i := range salt { - salt[i] = byte(r.IntN(256)) - } - return salt - }() -) - -func BenchmarkHashIter(b *testing.B) { - const password = "oboe shortness ether ideology undesired fresh freezable catching mashing glimpse" - for b.Loop() { - cryptoutil.HashIter(password, salt, iterations) - } -} - -func run() error { - const targetDuration = 2 * 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 - })) - return nil -} - -func main() { - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} -- cgit v1.3.1