Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privkey to wif #248

Open
Cyclopas opened this issue Jul 31, 2023 · 2 comments
Open

Privkey to wif #248

Cyclopas opened this issue Jul 31, 2023 · 2 comments

Comments

@Cyclopas
Copy link

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
Copy link
Owner

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants