示例#1
0
func main() {
	h, err := gocryptodev.New(gocryptodev.CRYPTO_SHA2_384)
	if err != nil {
		panic(err)
	}
	io.Copy(h, os.Stdin)
	fmt.Printf("%x\n", h.Sum(nil))
}
示例#2
0
func main() {
	h, err := gocryptodev.New(gocryptodev.CRYPTO_SHA1)
	if err != nil {
		panic(err)
	}
	buf := make([]byte, 1024*1024*2)
	for {
		n, err := os.Stdin.Read(buf)
		if err != nil {
			break
		}
		h.Write(buf[:n])
	}
	fmt.Printf("%x\n", h.Sum(nil))
}