1 // Copyright (c) 2015 The Decred developers
2 // Copyright (c) 2016-2017 The btcsuite developers
3 // Use of this source code is governed by an ISC
4 // license that can be found in the LICENSE file.
10 // HashB calculates hash(b) and returns the resulting bytes.
11 func HashB(b []byte) []byte {
12 hash := sha256.Sum256(b)
16 // HashH calculates hash(b) and returns the resulting bytes as a Hash.
17 func HashH(b []byte) Hash {
18 return Hash(sha256.Sum256(b))
21 // DoubleHashB calculates hash(hash(b)) and returns the resulting bytes.
22 func DoubleHashB(b []byte) []byte {
23 first := sha256.Sum256(b)
24 second := sha256.Sum256(first[:])
28 // DoubleHashH calculates hash(hash(b)) and returns the resulting bytes as a
30 func DoubleHashH(b []byte) Hash {
31 first := sha256.Sum256(b)
32 return Hash(sha256.Sum256(first[:]))