package e标签:EncodeToString,make,testing,hex,Write,shake,byte From: https://www.cnblogs.com/Janly/p/17204081.html
import (
"encoding/hex"
"fmt"
"golang.org/x/crypto/sha3"
"testing"
)
func TestName(t *testing.T) {
h := sha3.NewShake256()
h.Write([]byte("msg00"))
r := make([]byte, 136)
h.Read(r)
fmt.Println(hex.EncodeToString(r))
h.Reset()
h.Write([]byte("msg11"))
r = make([]byte, 200)
h.Read(r)
fmt.Println(hex.EncodeToString(r))
}
func TestShake(t *testing.T) {
h := NewSHAKE256(0)
h.Write([]byte("msg00"))
r := make([]byte, 136)
h.Sum(r)
if hex.EncodeToString(r) != "d28f82c4d5ac0d027c8fcf09ced8301f9fe45d7ae144f3f0e0367c1e36884595aff9f83e85e6724269a85fb8eb6467eb63b9e7fc81864b3c11b4ec9bc8c737103486f6f82ad37255f5e35e15e8594eaef9bb66c7263ad3a1e1ac81e21f08e7178acf175857d9907de25a9a0494da114e6f78192bdc7ce76e5a7c2762b46012233b398ff5e1d8886b" {
t.Fatal(r)
}
h.Reset()
h.Write([]byte("msg11"))
r = make([]byte, 200)
h.Sum(r)
if hex.EncodeToString(r) != "f4c3f4827ba85c3b353ce1bdefe19b9cca73589b55d13626b7e3e84e3d81241a2d554b790d21c0aa4cd68a2ab0b95b63b0d0990f5e31d9deb376784a78b90dd68e572368e741f08da2059edd11969d924dbf7fe6b438c4f69c318b89323335b78df8b8af75b305ceb99b4b740649b90beeed34462b29b0c01e1ce332272e4b00966934286544f6f9cdd5187b16a86133ef1ac9b47775c7ccdb98905b01d22724995a3e070afbbac28a9928d76820bc8748e0a89908cdfa0e061b1fc51c21a9a9feeddd9eadd12507" {
t.Fatal(r)
}
}