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
284 B

11 years ago
  1. package peer
  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)
  9. sum := hasher.Sum(nil)
  10. hasher.Reset()
  11. hasher.Write(sum)
  12. return hasher.Sum(nil)
  13. }