1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-05-13 15:21:20 +00:00

16 lines
331 B
Go
Raw Normal View History

2015-10-25 18:21:51 -07:00
package p2p
import (
"crypto/sha256"
)
// doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func doubleSha256(b []byte) []byte {
hasher := sha256.New()
2017-10-03 19:11:55 -04:00
_, _ = hasher.Write(b) // error ignored
2015-10-25 18:21:51 -07:00
sum := hasher.Sum(nil)
hasher.Reset()
2017-10-03 18:49:20 -04:00
_, _ = hasher.Write(sum) // error ignored
2015-10-25 18:21:51 -07:00
return hasher.Sum(nil)
}