keyhunt
keyhunt copied to clipboard
Privkey to wif
trafficstars
I've create a vanity address. Anyone that wants to convert privkey to wif heres a python code, where private_key_hex set the private key.
import hashlib
import base58
def private_key_to_wif(private_key_hex, compressed=False, prefix=b'\x80'):
if compressed:
private_key_hex += '01'
extended_key = prefix + bytes.fromhex(private_key_hex)
checksum = hashlib.sha256(hashlib.sha256(extended_key).digest()).digest()[:4]
extended_key_with_checksum = extended_key + checksum
wif = base58.b58encode(extended_key_with_checksum).decode('utf-8')
return wif
private_key_hex = ''
wif = private_key_to_wif(private_key_hex, compressed=True) # Change compressed=False to generate uncompressed WIF
print("Compressed WIF:", wif)
Thanks.
Also there is one trusted page to do that, you can download the page and run it on localhost. https://www.bitaddress.org/
Feel free to close it Alberto. Or leave it open just for refence. Thanks for your opensource hard work.