Web · real, tested code

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
##############  ##    ##    ##############
##          ##  ########    ##          ##
##  ######  ##      ##  ##  ##  ######  ##
##  ######  ##  ##  ##  ##  ##  ######  ##
##  ######  ##        ##    ##  ######  ##
##          ##        ####  ##          ##
##############  ##  ##  ##  ##############
                ##    ####                
##  ####  ######  ##  ####  ##    ##  ####
  ####  ####  ##  ############    ####    
##      ##  ##    ##  ##              ####
##  ####      ##      ##    ########  ##  
  ##  ############      ##    ##    ##  ##
                ########    ##      ##  ##
##############  ##    ####    ##          
##          ##  ##  ##        ##########  
##  ######  ##          ############  ####
##  ######  ##  ##  ####    ##  ########  
##  ######  ##  ####    ##  ####    ##    
##          ##      ##    ##  ####      ##
##############  ##  ##    ##  ##