Skip to content

Instantly share code, notes, and snippets.

@anddam
Created February 14, 2014 08:46
Show Gist options
  • Save anddam/8997785 to your computer and use it in GitHub Desktop.
Save anddam/8997785 to your computer and use it in GitHub Desktop.
Get bitcoin address from RIPEMD-160 hash in python
from hashlib import sha256
from base58 import b58encode
def get_address_from_ripemd160(ripemd_hash):
# steps from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
h3 = ripemd_hash
h4 = '00' + h3
h5 = sha256(h4.decode('hex')).hexdigest()
h6 = sha256(h5.decode('hex')).hexdigest()
h7 = h6[0:8]
h8 = h4 + h7
h9 = b58encode(h8.decode('hex'))
return h9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment