Create QR Codes With qrencode

thumbnail

For sharing URLs, WiFi, Bitcoin, and all your hacking needs

Neo
Tuesday, September 1, 2020

QR codes are an awesome technology

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:

  • Poor placement - Can be read in dark areas with poor lighting, or from obscure angles/orientations, and codes do not necessarily need to be flat/straight
  • Camera technologies - Cheap (even grayscale) cameras will work, thus new/hi-resolution cameras are not necessary
  • Display technologies - Hi-quality displays/prints are not necessary, meaning misprinting, low resolution or sloppy prints/displays are generally acceptable
  • Movement - Can usually be read even if they are moving, for example from the side of a truck or a moving billboard, granted that they are large enough
  • Partial damage - Using the highest error correction levels, QR codes can sustain up to 30% of missing/corrupted image data (eg scuffs and scrapes, graffiti and vandalism, etc)

Original QR Code Original QR Code

Damaged 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.

Install qrencode on your Mac or Linux machine

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

qrencode Examples

Note: For text with whitespace, enclose the string with single ( ‘ ) quotes. Or if you’re using apostrophes ( ‘ ) in your string, use double quotes ( “ ).

Generate a QR code as a PNG file and display it with Preview

qrencode -o qrcode.png 'https://neoevolutions.com' && open qrcode.png

https://neoevolutions.com

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).

Generate a QR code as ASCII and display it with your terminal

qrencode -o - -t ANSIUTF8 'https://twitter.com/neooeevo'

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.

Increase QR code decode reliability and robustness

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

https://neoevolutions.com/about

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.

Add qrencode shortcut functions to your .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;;'

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;;"

MECARD

Share a cool project you’ve been working on:

qrp 'https://podstacks.com'

https://podstacks.com

The possibilities are pretty much endless.

QRCode Monkey

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!

Take the Red Pill

you stay in wonderland

And I show you, how deep the rabbit hole goes.

OK!
We'll never share your email with anyone else.
Liked this post? Subscribe! I've heard my newsletter is pretty cool.
OK!