You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

21 lines
368 B

package p2p
import (
"crypto/sha256"
)
// doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
func doubleSha256(b []byte) []byte {
hasher := sha256.New()
_, err := hasher.Write(b)
if err != nil {
panic(err)
}
sum := hasher.Sum(nil)
hasher.Reset()
_, err = hasher.Write(sum)
if err != nil {
panic(err)
}
return hasher.Sum(nil)
}