Vendored a QR encoder in 522 lines
Vendored a QR encoder — Reed‑Solomon over GF(256), fixed module layout, eight mask patterns — in 522 lines rather than take a third runtime dependency, and verified it by reading the finished matrix back with an independently written decoder.
Work carried out: August 2026
522 lines of QR encoder, rather than a third dependency
Situation. The documents needed a QR code linking to the online version. Every available library does this, and taking one would have added a third runtime dependency to a project that had deliberately held itself to two — a template engine and a PDF renderer — on the argument that a document generator should still install years from now.
Task. Either accept the dependency or implement the format, and the implementation had to be verified as correct rather than merely producing something square and black.
Action. The encoder is 522 lines and implements the parts of the specification the use actually needs: byte‑mode encoding, Reed‑Solomon error correction over the Galois field of 256 elements with the generator polynomial built at the required degree, the fixed module layout with its finder patterns, timing patterns and alignment patterns, format and version information, and all eight data mask patterns evaluated against the specification’s four penalty rules so the lowest‑scoring mask is chosen rather than a fixed one. The verification is the part that made it defensible. Testing an encoder against its own logic proves nothing, so the finished module matrix is read back by a decoder written independently from the specification’s reading order, and the test asserts that the decoded string equals the input. That turns “it produces a plausible image” into “it produces a code that decodes to the right URL”, and it is checked on every run rather than once by eye with a phone.
Result. The runtime dependency count stayed at two, and the encoder is the only vendored component in the project. It should be said plainly that this is not a general‑purpose implementation — it supports the modes and versions the documents use and nothing else, and the honest justification is the dependency budget rather than any claim that the result is better than a mature library.

Photo: viarami / Pixabay 
Photo: 652234 / Pixabay
Bring this experience to your project
Use “Vendored a QR encoder in 522 lines” as a starting point for a similar challenge in your organisation. The services behind this work are available for your project. The shape of a system worked out on paper first, so the parts fit and the cost is known before anyone writes code.
Look behind the result
Read the situation, decisions and result in this example. We can discuss which parts transfer to your constraints and which need another approach. Vendored a QR encoder in 522 lines — 522 lines of QR encoder, rather than a third dependency
Look back at Enabled every linter rule as an error. Read next: Rehearsed the forge CI hook, found 2 defects. Or take a look at the full Portfolio.
One piece of a longer record — and it is all on this site.
Every entry is written the same way: the situation, the task, what we did and what changed.

