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

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. _, err := hasher.Write(b)
  9. if err != nil {
  10. panic(err)
  11. }
  12. sum := hasher.Sum(nil)
  13. hasher.Reset()
  14. _, err = hasher.Write(sum)
  15. if err != nil {
  16. panic(err)
  17. }
  18. return hasher.Sum(nil)
  19. }