parent
3235fbae2a
commit
16279258d0
@ -0,0 +1,26 @@ |
||||
package hash |
||||
|
||||
import ( |
||||
"github.com/ethereum/go-ethereum/common" |
||||
"golang.org/x/crypto/sha3" |
||||
) |
||||
|
||||
// Keccak256 calculates and returns the Keccak256 hash of the input data.
|
||||
func Keccak256(data ...[]byte) []byte { |
||||
d := sha3.NewLegacyKeccak256() |
||||
for _, b := range data { |
||||
d.Write(b) |
||||
} |
||||
return d.Sum(nil) |
||||
} |
||||
|
||||
// Keccak256Hash calculates and returns the Keccak256 hash of the input data,
|
||||
// converting it to an internal Hash data structure.
|
||||
func Keccak256Hash(data ...[]byte) (h common.Hash) { |
||||
d := sha3.NewLegacyKeccak256() |
||||
for _, b := range data { |
||||
d.Write(b) |
||||
} |
||||
d.Sum(h[:0]) |
||||
return h |
||||
} |
@ -1,8 +0,0 @@ |
||||
package crypto |
||||
|
||||
import "crypto/sha256" |
||||
|
||||
// HashSha256 returns result of Sha256.
|
||||
func HashSha256(message string) [32]byte { |
||||
return sha256.Sum256([]byte(message)) |
||||
} |
Loading…
Reference in new issue