larzqr
QR codes from scratch — real Reed-Solomon error correction, all eight masks, zero dependencies.
Most "pure Python" QR libraries stop at drawing squares. larzqr implements the
actual standard: Reed-Solomon ECC over GF(256), the finder / timing /
alignment patterns, BCH-coded format and version information, and penalty-based
mask selection — so the codes it emits are genuinely scannable. No numpy, no
pillow, no C extension. Just the standard library.
It covers QR versions 1 through 10 in byte mode (up to ~270 bytes at EC level L), which comfortably fits URLs, Wi-Fi configs, and TOTP provisioning URIs from larztotp.
Install
pip install larzqr
Use
from larzqr import QR
qr = QR("https://example.com")
print(qr.to_text()) # scannable straight from a terminal
qr = QR("otpauth://totp/App:alice?secret=JBSWY3DPEHPK3PXP&issuer=App",
error_correction="M") # L, M, Q, or H
qr.to_svg("login.svg", scale=10) # crisp vector output
qr.matrix # the raw list-of-lists 0/1 module grid
qr.version, qr.mask # picked automatically
Why it's correct, not just plausible
QR generators are easy to get almost right and impossible to eyeball. larzqr is anchored to published constants at every layer:
- Reed-Solomon is checked against the standard's worked v1-M example — data
codewords in, the exact ECC bytes
[196, 35, 39, 119, 235, 215, 231, 226, 93, 23]out. - Format information matches the spec table (M/mask0 =
0x5412, L/mask0 =0x77C4); version information matches the version-7 constant. - GF(256) products are verified against hand-computed values
(
2 · 128 = 0x1d). - Finder patterns, timing patterns, the dark module, and mask selection are all tested as structural invariants.
Tests
python -m unittest discover -s tests -v # 29 tests
The Larz stack
One of 60+ pure-Python, zero-dependency libraries at github.com/larz-scripter. Pairs naturally with larztotp (turn a provisioning URI into a scannable enrollment code) and larzhtml (drop the SVG straight into a page).
License
MIT (c) larz-scripter
Metadata
Release files for larzqr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzqr-0.1.0.tar.gz | 9.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzqr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / larzqr-0.1.0.tar.gz
| Download URL | larzqr-0.1.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e180b62705d96b2126b6a76516e3063e309ad51dcd7496f2938aa88c44f0f76
|
|
BLAKE2b-256 checksum How to use checksums |
2ca80d65fdcf4ab14f0872d7618d15d1588720211e6c21afcbab9b307f16e6b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzqr-0.1.0-py3-none-any.whl
| Download URL | larzqr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13c7471ce6f216afeadb17538858d8395a8ad59ca7a3ae21071519076a066d25
|
|
BLAKE2b-256 checksum How to use checksums |
1179689cacdc71e684a1fc489f18bf74a2de202676bdf217fe4011cf714e3ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzqr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.