Created
February 12, 2020 23:13
-
-
Save oconnor663/deabed6511386ea51195a09ae133064a to your computer and use it in GitHub Desktop.
a simple "hash stdin" CLI program using zeebo/blake3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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