Generate a QR Code in Larzscript
Encode text into a real, spec-accurate QR code - Reed-Solomon error correction and all - rendered as ASCII art.
Scoped to QR version 1 (21x21 modules, error-correction level M, byte mode) - small enough to implement and verify with real confidence; verify_roundtrip() decodes the generated matrix back through an independently-written reader to confirm it recovers the original text.
larzscript pkg install qr
Code
import "qr" as qr
let code = qr.generate("HELLO")
print(qr.verify_roundtrip("HELLO"))
print(qr.to_text(code))Output
true
############## ## ## ##############
## ## ######## ## ##
## ###### ## ## ## ## ###### ##
## ###### ## ## ## ## ## ###### ##
## ###### ## ## ## ###### ##
## ## #### ## ##
############## ## ## ## ##############
## ####
## #### ###### ## #### ## ## ####
#### #### ## ############ ####
## ## ## ## ## ####
## #### ## ## ######## ##
## ############ ## ## ## ##
######## ## ## ##
############## ## #### ##
## ## ## ## ##########
## ###### ## ############ ####
## ###### ## ## #### ## ########
## ###### ## #### ## #### ##
## ## ## ## #### ##
############## ## ## ## ## Related
larzqrReal spec-accurate QR code generation - Reed-Solomon error correction, all 8 mask patterns→Make an HTTP GET Request in LarzscriptFetch a URL and read its status code and body - or parse a JSON API response directly.→Sign and Verify a Webhook Payload in LarzscriptSign an outgoing webhook payload with HMAC-SHA256, and verify an incoming one - the same shape real payment/webhook providers use.→Hash Data with SHA-256 in LarzscriptCompute a real SHA-256 hash and an HMAC-SHA256 message authentication code.→