Lab note #74: QR Code Generator: a Wi-Fi, link and text code you can download

The ask

Paul asked whether the site could generate QR codes: a Wi-Fi option taking a network name and a password for WPA, WPA2 or an open network, plus a web address or plain text, with a PNG download. He then asked to drop WEP, to suggest a guest network because a Wi-Fi code is the same as publishing the password in text, and to build and stage it so he can test it with his phone camera.

What changed

  • New tool: QR Code Generator at /tools/qr-code-generator/, page 607, child of the Tools hub.
  • It builds a Wi-Fi, web address or text code in the browser, and shows the exact string the code carries so it can be checked or copied.
  • Wi-Fi covers WPA, WPA2 and WPA3 in one security choice, and an open network with no password field. WEP is not offered: the format that phones read treats all three WPA versions as one value, and WEP is obsolete.
  • Options: error correction L, M, Q or H, defaulting to M, and a standard screen size or a large print size, with the exact pixel size reported.
  • Download the code as a PNG, or copy the encoded text. Payloads, validation and drawing all run in the browser, with no server, no third party API and no storage.
  • A guest network caution sits next to the Wi-Fi fields, and a section below the tool explains what a Wi-Fi code exposes.
  • Tools hub: a fifth card, updated privacy wording, and an extra line in Who this is for.
  • Encoder: the MIT licensed QR Code generator library by Project Nayuki is saved with the site as pn-tools/assets/qrcodegen.js. The tool’s own script is pn-tools/assets/qr-code-generator.32888d4c6611.js. Nothing is loaded from a CDN.

How

OpenCode worked over SSH on openclaw01: read AGENTS.md and docs/GUIDELINES.md first, took a snapshot, used ops/wp.sh for the page and the hub, wrote the two asset files through the wpcli container as user 33:33, then recorded the change with ops/sync.sh. The encoder was verified against an independent decoder on the host, and the page was driven in Chrome with the browser tools.

What worked, what didn’t

  • 151 automated checks passed, including 52 encode and decode round trips through jsQR, a decoder written independently of the encoder. They covered Wi-Fi with a password, an open network, a hidden network, reserved characters in the name and password, a hexadecimal looking name, accented names, an emoji name, short and long URLs, text with punctuation and line breaks, and all four error correction levels.
  • The PNG that Chrome actually downloaded was decoded back to the exact expected Wi-Fi string, so payload building, encoding, drawing and the download are verified end to end, not just in theory.
  • The tests ran against the exact asset bytes served on staging, and the stored page content still carried both script tags after WordPress saved it.
  • In Chrome: an open network hid the password field, a hidden network added its flag, escaping produced the right string, an empty name and a short password produced clear errors and focused the offending field, a URL without a scheme warned but still built, the show password toggle did not clear the result, editing an input cleared a stale result, and both output sizes produced the sizes reported. No console errors or warnings.
  • At a 390 pixel layout there was no horizontal overflow, with a Wi-Fi payload and with a 170 character URL. That was a container width check in the desktop browser, not a physical phone viewport.
  • The vendored build encodes in one mode, so mixed case text such as a Wi-Fi string becomes a single byte segment. That can need one symbol version more than an engine with a full multi segment optimiser. The codes decode identically. The tool also tries the library’s own split and keeps the smaller symbol, which is what the version cross check against an independent encoder was for.
  • No colour choice is offered. Light on dark and low contrast codes fail on many phone cameras, so the symbol is drawn dark on light and the page says why.
  • Not verified: a real camera scan. A browser cannot stand in for a phone camera, so Paul will scan the code on his phone. That is the one check left before this should be called done.

Change record

Harnessopencode
Date2026-10-12 10:10
Latest snapshot20261012-095709
Undo this sessionops/rollback.sh --git baf9e99

Commits

  • 9b03f02 content: add the QR Code Generator tool, its encoder assets and its Tools hub card
  • c9280af scoreboard: refresh after Lab note #73