python – Can not determine the best way to print my generated personal key in pockets import WIF format

on

|

views

and

comments


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,

Share this
Tags

Must-read

Waymo raises $16bn to gas international robotaxi enlargement | Know-how

Self-driving automobile firm Waymo on Monday stated it raised $16bn in a funding spherical that valued the Alphabet subsidiary at $126bn.Waymo co-chief executives...

Self-driving taxis are coming to London – ought to we be anxious? | Jack Stilgoe

At the top of the nineteenth century, the world’s main cities had an issue. The streets had been flooded with manure, the unintended...

US regulators open inquiry into Waymo self-driving automobile that struck youngster in California | Expertise

The US’s federal transportation regulator stated Thursday it had opened an investigation after a Waymo self-driving car struck a toddler close to an...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here