https://github.com/jalfr3d/hex-to-wif
I don't trust online website that offer to do this and prefer to do it offline.
https://github.com/jalfr3d/hex-to-wif
btc-tool hex hextowif import-wallet private-key python script wif
Last synced: about 1 month ago
JSON representation
I don't trust online website that offer to do this and prefer to do it offline.
- Host: GitHub
- URL: https://github.com/jalfr3d/hex-to-wif
- Owner: jalfr3d
- Created: 2025-04-23T22:45:42.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-05-15T17:54:22.000Z (about 1 month ago)
- Last Synced: 2025-05-15T18:45:59.464Z (about 1 month ago)
- Topics: btc-tool, hex, hextowif, import-wallet, private-key, python, script, wif
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ BTC HEX to WIF Private Key Converter
This simple Python script converts a **Bitcoin private key in hexadecimal (HEX)** format into **WIF (Wallet Import Format)**. It supports both **compressed** and **uncompressed** formats.
## ๐ What It Does
- Takes a private key in HEX format (e.g., `730FC235C1942C1AE`)
- Pads it to 32 bytes if necessary
- Converts it to the WIF format
- Prints the WIF private key string## ๐งช Example
```python
import hashlib
import base58def private_key_to_wif(hex_key, compressed=True):
prefix = b'\x80'
key_bytes = bytes.fromhex(hex_key)
if compressed:
key_bytes += b'\x01'
extended_key = prefix + key_bytes
checksum = hashlib.sha256(hashlib.sha256(extended_key).digest()).digest()[:4]
wif = base58.b58encode(extended_key + checksum)
return wif.decode()# Example usage:
hex_priv = "730FC235C1942C1AE"
hex_priv = hex_priv.rjust(64, '0') # pad with zeros to full 32 bytes
wif = private_key_to_wif(hex_priv)
print(wif)
```## ๐งพ Output
```
L4RjWUyUf1Gc... (your WIF key will vary)
```## โ๏ธ Requirements
No external dependencies! Just Python's standard library:
-hashlib
-base58 (make sure to install this with pip)```
pip install base58
```
## ๐ง Options
Set compressed=False to generate an uncompressed WIF key.Ensure your private key is exactly 64 hex characters (32 bytes). The script automatically pads it if it's shorter.
## ๐ Use Cases
- Brute-force or puzzle-solving workflows
- Key conversions during wallet development
- Educational purposes## ๐ Disclaimer
This script is for educational and research purposes only. Use responsibly. Do not use on live/private wallets unless you understand what you're doing.