Browse Source

Add a blake2b_base32 cli tool

logo_rebranding
James Mills 3 months ago
parent
commit
0aa1d51c45
Signed by: prologic GPG Key ID: AC4C014F1440EBD6
  1. 26
      tools/blake2b_base32.go

26
tools/blake2b_base32.go

@ -0,0 +1,26 @@
package main
import (
"encoding/base32"
"fmt"
"io"
"os"
"strings"
"golang.org/x/crypto/blake2b"
)
func fastHash(s string) string {
sum := blake2b.Sum256([]byte(s))
// Base32 is URL-safe, unlike Base64, and shorter than hex.
encoding := base32.StdEncoding.WithPadding(base32.NoPadding)
hash := strings.ToLower(encoding.EncodeToString(sum[:]))
return hash
}
func main() {
data, _ := io.ReadAll(os.Stdin)
fmt.Print(fastHash(string(data)))
}
Loading…
Cancel
Save