dcrd/dcrutil/hash160.go
Dave Collins 6e647f731f
multi: Use crypto/ripemd160 module.
This updates the main, dcrutil, and blockchain modules to make use of
the new crypto/ripemd160 module.
2019-10-08 10:21:03 -05:00

25 lines
613 B
Go

// Copyright (c) 2013-2014 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package dcrutil
import (
"hash"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/crypto/ripemd160"
)
// Calculate the hash of hasher over buf.
func calcHash(buf []byte, hasher hash.Hash) []byte {
hasher.Write(buf)
return hasher.Sum(nil)
}
// Hash160 calculates the hash ripemd160(hash256(b)).
func Hash160(buf []byte) []byte {
return calcHash(chainhash.HashB(buf), ripemd160.New())
}