tendermint/p2p/util.go

16 lines
283 B
Go
Raw Normal View History

2014-07-07 20:03:50 -07:00
package p2p
2014-06-07 19:09:47 -07:00
import (
2014-07-01 14:50:24 -07:00
"crypto/sha256"
2014-06-07 19:09:47 -07:00
)
2014-07-09 14:27:32 -07:00
// doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func doubleSha256(b []byte) []byte {
2014-06-07 19:09:47 -07:00
hasher := sha256.New()
hasher.Write(b)
sum := hasher.Sum(nil)
hasher.Reset()
hasher.Write(sum)
return hasher.Sum(nil)
}