QR (“quick response”) codes are nearly 25 years old. They first appeared on the tech scene in 2000 and were invented by Japanese automotive components giant Denso as a way to identify parts in production.
Although most people think of QR codes as “that box I scan with my phone’s camera to go to a web site,” you can actually encode a LOT more in a QR code. If you’re using the Latin upper-case alphanumerics and common punctuation (0–9, A–Z, space, $, %, *, +, -, ., /, :) you can store 4,296 characters. And if you do, the QRs get mighty dense. Here’s 3,000 characters of Lorem Ipsum:
For numbers only, you can store 7,089 characters!
All info in a a QR code is stored in the image itself. There’s no “registered” a QR code or central QR code authority. If you encode a text to a QR code and someone on the other side of the world encode it, you’ll get the same image.
Shell Scripts
A while ago, we did a tutorial entitled “Using Google Authenticator for SSH and Console Connections to Your VPS“. This showed you how to setup your VPS so that when someone logged in, they were prompted for 2FA (Google Authenticator).
As part of that setup, the google-authenticator script displays a QR code in your terminal that you scan with your phone. Pretty neat. But that code is done via C code written by Google.
Is there a way mere mortals can do the same?
Yes! Via qrencode, which is in most distro’s package managers.
After a simple
apt install qrencode
you’ll have the ability to generate QR codes to your heart’s content.
Not only can qrencode spit out QRs in image formats like PNG, but it can produce text output QR codes that display in your terminal.
For example:
qrencode -m 2 -t utf8 <<< "https://www.lowendbox.com"
The -t flag sets output to text. You could do something like “-t png -f output.png” to save it as an image.
The -m flag sets the margin width. Default is 4 and here I’ve made it a little more snug for a smaller image.
And that’s all there is to generating QR codes easily from shell scripts.
Related Posts:
- Mango Mail’s Winter Sale is Only Here Until December 31! Act Now to Get Up to 6 Months Free on Quality Email Hosting - December 14, 2024
- Silicom Network’s Lifetime Deals Are Back!Get Started for $9 ONCE in Many Cities Around the World - December 13, 2024
- Hetzner Terminates Kiwix With Extreme Prejudice – What Do You Think? - December 11, 2024
Leave a Reply