(t *testing.T)
| 31 | return ret |
| 32 | } |
| 33 | func 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 | |
| 55 | func BenchmarkSm3(t *testing.B) { |
| 56 | t.ReportAllocs() |
nothing calls this directly
no test coverage detected
searching dependent graphs…