package sm3 import ( "hash" gmsm3 "github.com/emmansun/gmsm/sm3" ) type SM3 struct { h hash.Hash } func New() hash.Hash { s := &SM3{} s.Reset() return s } func (sm3 *SM3) BlockSize() int { return gmsm3.BlockSize } func (sm3 *SM3) Size() int { return gmsm3.Size } func (sm3 *SM3) Reset() { sm3.h = gmsm3.New() } func (sm3 *SM3) Write(p []byte) (int, error) { if sm3.h == nil { sm3.Reset() } return sm3.h.Write(p) } func (sm3 *SM3) Sum(in []byte) []byte { if sm3.h == nil { sm3.Reset() } return sm3.h.Sum(in) } func Sm3Sum(data []byte) []byte { sum := gmsm3.Sum(data) out := make([]byte, len(sum)) copy(out, sum[:]) return out }