diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2026-10-20 16:10:18 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2026-10-20 16:33:08 -0700 |
| commit | 78ff3c607a6b7252c872ee6393c504d87c371489 (patch) | |
| tree | 16773e064500935d7ff59436db51c87083a678cb /tools | |
| parent | Add a link to temporarily log in another device (diff) | |
| download | roseh.moe-78ff3c607a6b7252c872ee6393c504d87c371489.tar.zst | |
Remove a lot of files that aren't necessary
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/auth/auth.go | 68 | ||||
| -rw-r--r-- | tools/finditer/finditer.go | 60 | ||||
| -rw-r--r-- | tools/hashpw/hashpw.go | 53 |
3 files changed, 0 insertions, 181 deletions
diff --git a/tools/auth/auth.go b/tools/auth/auth.go deleted file mode 100644 index 6268ba8..0000000 --- a/tools/auth/auth.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2026 Rose Hogenson <r@roseh.moe> -// -// This file is part of roseh.moe. -// -// roseh.moe is free software: you can redistribute it and/or modify it -// under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// roseh.moe is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public -// License along with roseh.moe. If not, -// see <https://www.gnu.org/licenses/>. - -package main - -import ( - "encoding/base32" - "encoding/base64" - "encoding/xml" - "flag" - "fmt" - "os" - - "github.com/skip2/go-qrcode" -) - -func run() error { - args := flag.Args() - if len(args) != 1 { - return fmt.Errorf("usage: auth <config file>") - } - fileBytes, err := os.ReadFile(args[0]) - if err != nil { - return err - } - var config struct { - AuthKey string `xml:",attr"` - } - if err := xml.Unmarshal(fileBytes, &config); err != nil { - return err - } - if config.AuthKey == "" { - return fmt.Errorf("%s: missing AuthKey", args[0]) - } - authKey, err := base64.StdEncoding.DecodeString(config.AuthKey) - if err != nil { - return err - } - qrCode, err := qrcode.New(fmt.Sprintf("otpauth://totp/roseh.moe:rose?secret=%s&issuer=roseh.moe", base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(authKey)), qrcode.Medium) - if err != nil { - return err - } - fmt.Print(qrCode.ToSmallString(false)) - return nil -} - -func main() { - flag.Parse() - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} diff --git a/tools/finditer/finditer.go b/tools/finditer/finditer.go deleted file mode 100644 index f5bf75f..0000000 --- a/tools/finditer/finditer.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2026 Rose Hogenson <r@roseh.moe> -// -// This file is part of roseh.moe. -// -// roseh.moe is free software: you can redistribute it and/or modify it -// under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// roseh.moe is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public -// License along with roseh.moe. If not, -// see <https://www.gnu.org/licenses/>. - -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 -} - -var salt = mustHex("34539b5dd2591415") - -var iter int - -func BenchmarkHashIter(b *testing.B) { - const password = "wavy upend 4z jk linda k zing four atop pi" - for b.Loop() { - pwhash.HashIter(password, salt, iter) - } -} - -func main() { - const targetTime = 5 * time.Second - for iter = 8192; time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) < targetTime; iter *= 2 { - } - lo := iter / 2 - hi := iter - fmt.Println(lo + sort.Search(hi-lo, func(n int) bool { - iter = lo + n - return time.Duration(testing.Benchmark(BenchmarkHashIter).NsPerOp()) > targetTime - })) -} diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go deleted file mode 100644 index 8244b64..0000000 --- a/tools/hashpw/hashpw.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2026 Rose Hogenson <r@roseh.moe> -// -// This file is part of roseh.moe. -// -// roseh.moe is free software: you can redistribute it and/or modify it -// under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, -// or (at your option) any later version. -// -// roseh.moe is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public -// License along with roseh.moe. If not, -// see <https://www.gnu.org/licenses/>. - -package main - -import ( - "crypto/rand" - "encoding/base64" - "fmt" - "os" - - "golang.org/x/term" - "roseh.moe/pkg/roseh.moe/internal/pwhash" -) - -func hashpw() error { - fmt.Fprint(os.Stderr, "Enter password: ") - pw, err := term.ReadPassword(int(os.Stdin.Fd())) - fmt.Fprintln(os.Stderr) - if err != nil { - return err - } - salt := make([]byte, pwhash.SaltSize) - rand.Read(salt) - pwHash, err := pwhash.Hash(string(pw), salt) - if err != nil { - return err - } - fmt.Printf("NotepadPassword=\"%s\"\n", base64.StdEncoding.EncodeToString(append(salt, pwHash...))) - return nil -} - -func main() { - if err := hashpw(); err != nil { - fmt.Fprintf(os.Stderr, "hashpw: %s\n", err) - os.Exit(1) - } -} |
