Skip to content

Instantly share code, notes, and snippets.

@bjarnemagnussen
Created May 9, 2020 15:46
Show Gist options
  • Save bjarnemagnussen/f6d72a6ce25fd51f060b311c5654a761 to your computer and use it in GitHub Desktop.
Save bjarnemagnussen/f6d72a6ce25fd51f060b311c5654a761 to your computer and use it in GitHub Desktop.
from hashlib import new, sha256 as _sha256, sha512 as _sha512
import hmac as _hmac
from coincurve import PrivateKey as ECPrivateKey, PublicKey as ECPublicKey
def sha256(bytestr):
return _sha256(bytestr).digest()
def double_sha256(bytestr):
return _sha256(_sha256(bytestr).digest()).digest()
def double_sha256_checksum(bytestr):
return double_sha256(bytestr)[:4]
def ripemd160_sha256(bytestr):
return new('ripemd160', sha256(bytestr)).digest()
hash160 = ripemd160_sha256
def hmac_sha512(key, bytestr):
return _hmac.new(key, bytestr, _sha512).digest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment