github.com/chain5j/chain5j-pkg@v1.0.7/crypto/hashalg/crypto_hash.go (about) 1 // Package hashalg 2 // 3 // @author: xwc1125 4 package hashalg 5 6 import ( 7 "github.com/chain5j/chain5j-pkg/codec/rlp" 8 "github.com/chain5j/chain5j-pkg/crypto/hashalg/sha3" 9 "github.com/chain5j/chain5j-pkg/types" 10 ) 11 12 // RlpHash keccak256Hash 13 func RlpHash(x interface{}) (h types.Hash, err error) { 14 hw := sha3.NewKeccak256() 15 err = rlp.Encode(hw, x) 16 if err != nil { 17 return types.Hash{}, err 18 } 19 hw.Sum(h[:0]) 20 return h, nil 21 }