Skip to content

Instantly share code, notes, and snippets.

@oconnor663
Created February 12, 2020 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oconnor663/deabed6511386ea51195a09ae133064a to your computer and use it in GitHub Desktop.
Save oconnor663/deabed6511386ea51195a09ae133064a to your computer and use it in GitHub Desktop.
a simple "hash stdin" CLI program using zeebo/blake3
package main
import (
"encoding/hex"
"fmt"
"io"
"os"
"github.com/zeebo/blake3"
)
func main() {
buf := [65536]byte{}
hasher := blake3.New()
for {
n, err := os.Stdin.Read(buf[:])
hasher.Write(buf[:n])
if err == io.EOF {
break
} else if err != nil {
panic(err)
}
}
hash := hasher.Sum([]byte{})
fmt.Println(hex.EncodeToString(hash))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment