Convert binary files to QR codes and back
Project description
Binary QR Converter
A simple CLI tool to convert binary files to QR codes and back.
Features
- Convert any binary file to a series of QR codes
- Decode QR codes back to the original binary file
- Compression to reduce the number of QR codes needed
- Error correction for reliable decoding
- File integrity verification using SHA-256 hashing
- Cross-platform compatibility (Windows, macOS, Linux)
Prerequisites
- Python 3.6 or higher
- For decoding QR codes, you need to install the ZBar library:
- On Ubuntu/Debian:
sudo apt-get install libzbar0 - On macOS:
brew install zbar - On Windows: Download from SourceForge
- On Ubuntu/Debian:
Setup
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txt - Make the script executable (Linux/macOS):
chmod +x binary_qr.py
Usage
Encoding a binary file to QR codes
python binary_qr.py encode path/to/file.bin -o output_directory
Options:
-o, --output-dir: Directory to save QR code images (default: ./qrcodes)-c, --chunk-size: Size of binary chunks in bytes (default: 1024)-v, --qr-version: QR code version (1-40, higher means more capacity) (default: 40)-z, --compression-level: Zlib compression level (0-9) (default: 9)
Decoding QR codes back to a binary file
python binary_qr.py decode path/to/qrcodes/*.png -o output_directory
or
python binary_qr.py decode path/to/qrcodes/ -o output_directory
Options:
-o, --output-dir: Directory to save the reconstructed file (default: ./output)
Show version information
python binary_qr.py version
Examples
Encode a PDF file to QR codes
python binary_qr.py encode document.pdf -o qrcodes/
Decode QR codes back to the original PDF
python binary_qr.py decode qrcodes/ -o recovered/
Run the example script
python example.py
How it works
- The binary file is compressed using zlib to reduce size
- The compressed data is split into chunks
- Each chunk is encoded with metadata (chunk index, total chunks, filename, file hash)
- Each chunk with metadata is converted to a QR code image
- When decoding, the QR codes are read, and the chunks are reassembled
- The reassembled data is decompressed to recover the original file
- The file hash is verified to ensure data integrity
Tips for optimal use
- Adjust chunk size: For larger files, increasing the chunk size (
-coption) can reduce the number of QR codes but may make them more complex and harder to scan. - QR code version: Higher versions (up to 40) can store more data but require higher resolution scanning.
- Compression level: The default level (9) provides maximum compression but takes longer. Lower values (1-8) are faster but produce more QR codes.
- Printing QR codes: When printing, ensure high quality and sufficient size for reliable scanning.
- Scanning: Use a good camera in well-lit conditions for best results when scanning QR codes.
Troubleshooting
- Missing ZBar library: If you get an error about missing ZBar, install it using the instructions in the Prerequisites section.
- QR code decoding fails: Make sure all QR codes are clearly visible and not damaged. Try increasing the error correction level.
- File too large: Try increasing the chunk size or QR code version to reduce the number of QR codes.
- Invalid QR version: Make sure to use a QR version between 1 and 40.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binary_qr_converter-0.1.0.tar.gz.
File metadata
- Download URL: binary_qr_converter-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
098ecd80d7b1b4f49e946d01cf8a35df2d5e1fc9bff3486376ded0ee2a67babf
|
|
| MD5 |
86dc1571cde45bca0c2afa23b80afab4
|
|
| BLAKE2b-256 |
bbc672a46a9a339f4578a4d5c3090135e172698f5fde05138e4df7a73f2bb6c4
|
File details
Details for the file binary_qr_converter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: binary_qr_converter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99fc04baf5054eeaa420d8eee3b277fb8a5dcbfc464ac5f3416b52ce13c43231
|
|
| MD5 |
2545384cdb3a87396ac104669425102d
|
|
| BLAKE2b-256 |
9895edc86297bfc99a87016e7358fcb5bca5a3b13e2d6b433b28623d3413d3cc
|