QR (Quick Response) codes were released in 1994 by Denso Wave and were designed with the intention of creating a robust barcode for merchants that could be read quickly and accurately at almost any visible angle.
QR codes use a well-known communications algorithm known as Reed-Solomon forward error correction (aka RS-FEC) to encode and decode data into a 2D matrix barcode which can be read by nearly any device with a camera (eg. your phone, tablet , or computer) or 2D laser.
For all you non-techies out there, those funky looking black-and-white square images that you see on ads sometimes can pretty much guarantee that you can accurately read back the information stored within the QR code in all sorts of real-life conditions:
Original QR Code
This one still works!
That’s pretty freaking amazeballs for a 26-year old technology.
Personally, I use QR codes for transferring/sharing long strings like passwords, URLS, or API keys when a text message or other methods are too heavy, insecure, or just not hacker-ish enough.
In this post, I’ll show you the basics of qrencode, a popular command line tool for generating QR codes from any text of your choosing.
This is pretty easy to do if you have a Mac with Homebrew.
brew update && brew install qrencode
Or for Linux users
apt-get update && apt-get install qrencode
Note: For text with whitespace, enclose the string with single ( ‘ ) quotes. Or if you’re using apostrophes ( ‘ ) in your string, use double quotes ( “ ).
qrencode -o qrcode.png 'https://neoevolutions.com' && open qrcode.png
The above command will generate the QR image qrcode.png
with the above URL and open it with your default application for handling PNG images (eg Preview if you’re on a Mac).
qrencode -o - -t ANSIUTF8 'https://twitter.com/neooeevo'
The following will generate a QR code and display it using ASCII block characters.
Outputting codes directly to the terminal is incredibly useful when you need a one-time use QR code for passwords, and other sensitive data.
If your QR code has a lot of data, or if you anticipate that the code will be compromised in some way and need very high decode reliability, set the error correction flag to high by adding -l H
.
qrencode -o ~/Downloads/qrcode.png -l H 'https://neoevolutions.com/about' && open ~/Downloads/qrcode.png
Note: Increasing the error correction level adds data redundancy in the encoded image, meaning more dots/pixels, and results in a physically larger barcode image to display.
.bash_profile
Be a 1337 h4x012 and add these functions to your shell profile:
### My qrencode shortcut functions
# Output to terminal
qr() { qrencode -o - -t ANSIUTF8 $1; }
# Output to PNG to Downloads folder and open in Preview
qrp() { qrencode -o ~/Downloads/qrcode.png $1; open ~/Downloads/qrcode.png; }
Create a QR code to join WiFi hotspots on Android and iOS 11+:
qrp 'WIFI:S:DOPE-WIFI-AP;T:WPA;P:sweet-password-bro;;'
Or share your contact (in MECARD format):
qrp "MECARD:N:Evolution,Neo;\
NICKNAME:Neo;\
TEL:987-654-3210;\
EMAIL:neosearhole@gmail.com;\
BDAY:177674;\
NOTE:You're the coolest person ever. Let's be friends.;\
ADR:,,1337 Hacker Loop,Los Angeles,CA,90210,USA;\
URL:https://neoevolutions.com;;"
Share a cool project you’ve been working on:
qrp 'https://podstacks.com'
The possibilities are pretty much endless.
I’m not sponsored by them, but you can check out qrcode-monkey and avoid the command line to create specialized codes for sharing:
Happy hacking!