github.com/chain5j/chain5j-pkg@v1.0.7/crypto/signature/gmsm/hash.go (about) 1 // Package gmsm 2 // 3 // @author: xwc1125 4 package gmsm 5 6 import ( 7 "github.com/chain5j/chain5j-pkg/types" 8 "github.com/tjfoc/gmsm/sm3" 9 ) 10 11 // Gm3Hash GM3摘要算法 12 func Gm3Hash(data []byte) (h types.Hash) { 13 bytes := Gm3HashBytes(data) 14 return types.BytesToHash(bytes) 15 } 16 17 // Gm3HashBytes SM3密码杂凑算法 18 func Gm3HashBytes(data []byte) []byte { 19 h := sm3.New() 20 h.Write(data) 21 sum := h.Sum(nil) 22 return sum 23 }