MCPcopy
hub / github.com/tjfoc/gmsm / TestSm3

Function TestSm3

sm3/sm3_test.go:33–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31 return ret
32}
33func TestSm3(t *testing.T) {
34 msg := []byte("test")
35 err := ioutil.WriteFile("ifile", msg, os.FileMode(0644)) // 生成测试文件
36 if err != nil {
37 t.Fatal(err)
38 }
39 msg, err = ioutil.ReadFile("ifile")
40 if err != nil {
41 t.Fatal(err)
42 }
43 hw := New()
44 hw.Write(msg)
45 hash := hw.Sum(nil)
46 fmt.Println(hash)
47 fmt.Printf("hash = %d\n", len(hash))
48 fmt.Printf("%s\n", byteToString(hash))
49 hash1 := Sm3Sum(msg)
50 fmt.Println(hash1)
51 fmt.Printf("%s\n", byteToString(hash1))
52
53}
54
55func BenchmarkSm3(t *testing.B) {
56 t.ReportAllocs()

Callers

nothing calls this directly

Calls 5

byteToStringFunction · 0.85
Sm3SumFunction · 0.85
NewFunction · 0.70
WriteMethod · 0.45
SumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…