With out altering my code or modules I wish to print the personal key in WIF format. I am studying and browse a lot of articles however everybody appears to have a unique means of doing this. Any assist can be appreciated thanks
import hashlib
import ecdsa
import base58
# Seed for Personal Bitcoin Key
passphrase="secreate password"
#Hash the passphrase utilizing SHA256
passphrase = hashlib.sha256(passphrase.encode()).hexdigest()
# Create a brand new personal key utilizing the passphrase hash
private_key = ecdsa.SigningKey.from_string(bytes.fromhex(passphrase), curve=ecdsa.SECP256k1)
# Get the general public key
public_key = private_key.get_verifying_key()
# Add the prefix "04" to the general public key
public_key = "04" + public_key.to_string().hex()
# Legacy deal with
deal with = hashlib.new('ripemd160')
deal with.replace(hashlib.sha256(bytes.fromhex(public_key)).digest())
deal with="00" + deal with.hexdigest()
deal with = deal with + hashlib.sha256(hashlib.sha256(bytes.fromhex(deal with)).digest()).hexdigest()[:8]
legacy_address = base58.b58encode(bytes.fromhex(deal with)).decode()
print(f"Personal Key: {private_key.to_string().hex()}, Legacy Key: {legacy_address} ")
I can not determine the best way to print the personal key so it is wif format,
