Skip to content

makepkg/text-to-bip39-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 BIP-39 Data Converter (Base2048 Archiver)

A lightweight, standalone, and completely offline Python utility designed to convert arbitrary text, keys, passwords, or data into a list of words from the standard BIP-39 wordlist (or their respective numerical indices) and back.

It utilizes zlib compression to minimize the output length, making it highly efficient for backing up credentials, seeds, or configurations on paper or offline storage.


⚙️ How It Works

1. Encoding (Compression & Serialization)

$$\text{Plain Text} \xrightarrow{\text{zlib (Level 9)}} \text{Bytes} \xrightarrow{\text{Prepend } \mathtt{0x01}} \text{Big Integer} \xrightarrow{\text{Base2048 Conversion}} \text{BIP-39 Words}$$

  • Compression: The text is compressed using zlib with the maximum compression level (9) to reduce size.
  • Padding Protection: A prefix byte (0x01) is prepended to the compressed bytes. This guarantees that any leading zero bytes are preserved during integer conversion.
  • Base2048 Encoding: The resulting large integer is converted into base-2048, mapping directly to the standard 2048-word BIP-39 wordlist.

2. Decoding (Deserialization & Decompression)

$$\text{BIP-39 Input} \xrightarrow{\text{Reconstruct Big Integer}} \text{Bytes} \xrightarrow{\text{Strip } \mathtt{0x01}} \text{Compressed Bytes} \xrightarrow{\text{zlib Decompress}} \text{Original Text}$$

  • Reconstruction: The BIP-39 words or indices are converted back into a large integer.
  • Prefix Stripping: The integer is serialized back to bytes, and the prepended 0x01 byte is removed.
  • Decompression: The remaining bytes are decompressed via zlib to restore the exact original text.

🌐 Web Interface (GUI Mode)

We provide a standalone, responsive web interface in index.html.

  • Zero Dependencies: It uses native browser APIs (CompressionStream / DecompressionStream) for compression and decompression.
  • 100% Offline: You can download index.html and open it on any air-gapped computer without an internet connection.
  • Easy to Use: A beautiful tabbed layout for encoding and decoding with one-click copy-to-clipboard buttons.

🛠️ CLI Usage Instructions

This script is designed to be highly versatile. You can run it in three different ways:

1. Interactive CLI Mode (Easiest)

Simply run the script with no arguments. It will prompt you interactively:

python bip39_converter.py

Interactive Prompt:

[ BIP-39 DATA CONVERTER ]
1. Encode text (Compress -> BIP-39 words)
2. Decode BIP-39 data (Words/Indices -> Original text)
Select an option (1 or 2): 

2. Command Line Arguments (CLI Mode)

Perfect for terminal usage, scripting, and pipelines:

  • To Encode:
    python bip39_converter.py --encode "my super secret password or private key"
  • To Decode:
    python bip39_converter.py --decode "fog alone couch below powder"

3. Inline Configuration Mode (IDE/No-Terminal friendly)

If you prefer opening the script in an editor (like VS Code, PyCharm, or IDLE), you can modify the configuration panel at the bottom of bip39_converter.py:

# --- QUICK CONFIGURATION ---
TEXT_TO_ENCODE = """Your text goes here"""
WORDS_TO_DECODE = """"""

📋 Supported Decode Input Formats

The parser is highly flexible and automatically detects the input format:

  1. Space-separated BIP-39 Words:
    fog alone couch below powder
    
  2. Space-separated Indices:
    722 55 391 166 1353
    
  3. Dash-separated Indices:
    722-55-391-166-1353
    
  4. 4-Digit Zero-Padded Dash-Separated Indices:
    0722-0055-0391-0166-1353
    

🔒 Security & Privacy

  • Offline First: The script has zero external dependencies and uses only Python standard library modules (zlib, re, sys, hashlib, argparse).
  • No Network Activity: It does not make any network requests.
  • Deterministic: The encoding is fully deterministic; encoding the same text with the same zlib implementation will yield the exact same word sequence.

📄 License & Contributions

This project is open-source and licensed under the MIT License.

Contributions, bug reports, and feature suggestions are welcome! Feel free to fork this repository, submit Pull Requests, or open Issues.

About

A lightweight tool to compress and encode arbitrary text/data into BIP-39 word sequences (Base2048) and decode them back.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors