NAME

Airlock::QR - QR codes as SVG, terminal blocks or data URI, in pure Perl

VERSION

version 0.001

SYNOPSIS

my $qr = Airlock::QR->new( text => $verification_uri_complete );

print $qr->svg;                                  # for the web
print '<img src="'.$qr->data_uri.'">';           # inline
binmode STDOUT, ':encoding(UTF-8)';
print $qr->terminal;                             # for a CLI

DESCRIPTION

Two places in a device flow want a QR code: the link to the approval page, so a phone can scan what a laptop or a CLI shows, and the otpauth:// URI when someone enrols a TOTP secret. This class renders both without an image library.

Encoding is done by GD::Barcode::QRcode, which is pure Perl and needs no GD for the matrix.

text

Required. What the code says. Characters outside ASCII are encoded as UTF-8.

ecc

Error correction level: L, M, Q or H. Default M.

quiet

Width of the empty border, in modules. Default 4, which is what the standard asks for.

encoder

Optional. Coderef called with the bytes and the error correction level, returning the code as lines of 0 and 1. Replaces the built-in encoder.

matrix

The code as rows of 0 and 1, without border. For own renderings.

max_bytes

Longest text, in bytes, this class encodes. 1000.

size

Modules per side, without border.

svg

my $svg = $qr->svg;

The code as a standalone SVG element, black on white, one unit per module. Scale it with CSS.

data_uri

my $src = $qr->data_uri;

The SVG as a data: URI for an img element.

terminal

binmode STDOUT, ':encoding(UTF-8)';
print $qr->terminal;
print $qr->terminal( ansi => 0 );

The code as Unicode half blocks, two modules per line of text. Returns characters, so the output handle needs an encoding layer. With ANSI colours, the default, it is black on white whatever the terminal theme; ansi => 0 leaves the colours out and assumes light text on a dark background.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-airlock/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.