github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/btcutil/hash160.go (about) 1 // Copyright (c) 2013-2014 The btcsuite developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package btcutil 6 7 import ( 8 "hash" 9 10 "github.com/mit-dci/lit/crypto/fastsha256" 11 "github.com/mit-dci/lit/crypto/ripemd160" 12 ) 13 14 // Calculate the hash of hasher over buf. 15 func calcHash(buf []byte, hasher hash.Hash) []byte { 16 hasher.Write(buf) 17 return hasher.Sum(nil) 18 } 19 20 // Hash160 calculates the hash ripemd160(sha256(b)). 21 func Hash160(buf []byte) []byte { 22 return calcHash(calcHash(buf, fastsha256.New()), ripemd160.New()) 23 }