• Hash256
  • Hash160
  • Reverse Bytes
  • Hexadecimal
  • Satoshis
Youtube

WIF Private Key

An easy to share format of a private key.

A private key can be converted in to a “Wallet Import Format”, which basically makes it easier to copy and move around.

Try it!

Mainnet
Testnet
True
False
 

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:

  1. Version Byte prefix - Indicates which network the private key is to be used on.
    • 0x80 = Mainnet
    • 0xEF = Testnet
  2. Compression Byte suffix (optional) - Indicates if the private key is used to create a compressed public key.
    • 0x01
  3. 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.

Code

Note: This code requires the checksum.rb and base58_encode.rb functions.

# Convert Private Key to WIF
privatekey = "ef235aacf90d9f4aadd8c92e4b2562e1d9eb97f0df9ba3b508258739cb013db2"
extended = "80" + privatekey + "01"
extendedchecksum = extended + checksum(extended)
wif = base58_encode(extendedchecksum)

puts wif

By Greg Walker,

Last Updated: 19 Apr 2020
  • 19 Apr 2020: added ajax-loading html and disabled ajax buttons when making ajax requests
  • 18 Apr 2020: typo
  • 15 Apr 2020: updated latest tools for consistency
  • 14 Apr 2020: added wif converter tool
  • 02 Apr 2020: added grades
  • 28 Mar 2020: updated html for h1 headers and subheadings - now dynamic from yaml
  • 28 Mar 2020: updated html for h1 headers and subheadings
  • 09 Oct 2019: renamed browser to explorer, glossary to guide, and guide to beginners
Back to Top

Hey there, it's Greg.

I'll let you know about cool website updates, or if something seriously interesting happens in bitcoin.


Don't worry, it doesn't happen very often.