Skip to content

Instantly share code, notes, and snippets.

View lerasah's full-sized avatar
🏎️

Sachethana Pathirage lerasah

🏎️
View GitHub Profile
@Jun-Wang-2018
Jun-Wang-2018 / Bitcoin_from_private_key_to_WIF.py
Last active December 25, 2023 23:49
From private key(hex) to Wallet Import Format(WIF)
# From private key(hex) to Wallet Import Format(WIF)
# Reference: https://medium.freecodecamp.org/how-to-create-a-bitcoin-wallet-address-from-a-private-key-eca3ddd9c05f
# https://docs.python.org/2/library/hashlib.html
import codecs #If not installed: "pip3 install codecs"
import hashlib
# PK0 is a demo private key.
PK0 = "841846de7afbe32ee7ded837872c6e0825db095275b8afed0000000000000000"
PK1 = '80'+ PK0
PK2 = hashlib.sha256(codecs.decode(PK1, 'hex'))
PK3 = hashlib.sha256(PK2.digest())