albertobsd / keyhunt

privkey hunt for crypto currencies that use secp256k1 elliptic curve
MIT License
640 stars 349 forks source link

Privkey to wif #248

Open Cyclopas opened 1 year ago

Cyclopas commented 1 year ago

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)
albertobsd commented 1 year ago

Thanks.

Also there is one trusted page to do that, you can download the page and run it on localhost. https://www.bitaddress.org/

Cyclopas commented 1 year ago

Feel free to close it Alberto. Or leave it open just for refence. Thanks for your opensource hard work.