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.

15 lines
323 B

9 years ago
9 years ago
9 years ago
  1. package p2p
  2. import (
  3. "crypto/sha256"
  4. )
  5. // doubleSha256 calculates sha256(sha256(b)) and returns the resulting bytes.
  6. func doubleSha256(b []byte) []byte {
  7. hasher := sha256.New()
  8. hasher.Write(b) // nolint: errcheck
  9. sum := hasher.Sum(nil)
  10. hasher.Reset()
  11. hasher.Write(sum) // nolint: errcheck
  12. return hasher.Sum(nil)
  13. }