A private key can be converted in to a “Wallet Import Format”, which basically makes it easier to copy and move around (because it’s shorter and contains a checksum for detecting errors).
You should never enter your private key in to a website, or use a private key generated by a website. Websites can save these private keys and use them to steal any bitcoins you send to its address.
How to create a WIF private key.
A WIF private key is a standard private key, but with a few added extras:
- Version Byte prefix - Indicates which network the private key is to be used on.
- Compression Byte suffix (optional) - Indicates if the private key is used to create a compressed public key.
- Checksum - Useful for detecting errors/typos when you type out your private key.
This is all then converted to Base58, which shortens the entire thing and makes it easier to transcribe…
A WIF private key is just another way of representing your original private key. If you have a WIF private key, you can always convert it back in to its original format.
# Convert Private Key to WIF
privatekey = "80" + privatekey + "01"
extendedchecksum = extended + checksum(extended)
wif = base58_encode(extendedchecksum)