Created
February 14, 2014 08:46
-
-
Save anddam/8997785 to your computer and use it in GitHub Desktop.
Get bitcoin address from RIPEMD-160 hash in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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