From 7ca3cfca6e683a318eedb907e4ba9c257d117b33 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Fri, 15 Aug 2025 14:53:56 -0300 Subject: wrapping up for a public release --- tools/pwdhash.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tools/pwdhash.go (limited to 'tools') diff --git a/tools/pwdhash.go b/tools/pwdhash.go new file mode 100644 index 0000000..e66f72f --- /dev/null +++ b/tools/pwdhash.go @@ -0,0 +1,33 @@ +package main + +import ( + "crypto/rand" + "crypto/sha256" + "encoding/hex" + "fmt" + "os" +) + +func main() { + if len(os.Args) <= 1 { + fmt.Printf("usage: pwdhash PASSWORD\n") + return + } + + fmt.Printf("password = \"%v\"\n", os.Args[1]) + + var salt [32]byte + if n, err := rand.Read(salt[:]); err != nil || n != 32 { + fmt.Printf("Failed to generate salt: %v\n", err) + } + + secret := sha256.Sum256([]byte(os.Args[1])) + for i := 0; i < 32; i += 1 { + secret[i] ^= salt[i] + } + + pwdhash := sha256.Sum256(secret[:]) + + fmt.Printf("pwdhash = %v\n", hex.EncodeToString(pwdhash[:])) + fmt.Printf("salt = %v\n", hex.EncodeToString(salt[:])) +} -- cgit v1.2.3