Skip to content

Instantly share code, notes, and snippets.

@jrussett
Last active July 10, 2020 20:07
Show Gist options
  • Save jrussett/ce16952ab7853a1eead5a0e6c14c686a to your computer and use it in GitHub Desktop.
Save jrussett/ce16952ab7853a1eead5a0e6c14c686a to your computer and use it in GitHub Desktop.
Easily generate QR codes and decode QR code images

QR Codes

Prerequisites

brew update
brew install qrencode zbar

Generating QR codes

qrencode -t ASCII -o - "${STRING_TO_ENCODE}"

Read QR Codes from file sources

zbarimg /path/to/qr.{png,jpg,..}

Generate a QR code for One Time Password auth example:

Code

#!/bin/bash

export label="My OTP"
export account="account@domain.tld"
export key="rs2Jre9b5hqd8zWd"

URL="otpauth://totp/${label}:${account}?secret=${key}&issuer=${label}"

qrencode -t ASCIIi -o - "${URL}"

Execution

$ ./generate.sh
##################################################################################
##################################################################################
##################################################################################
##################################################################################
########              ##################  ##      ####  ####              ########
########  ##########  ##  ##  ##  ##          ##  ##  ######  ##########  ########
########  ##      ##  ####    ##  ####  ########    ########  ##      ##  ########
########  ##      ##  ##      ##    ##      ########  ######  ##      ##  ########
########  ##      ##  ####            ##  ####          ####  ##      ##  ########
########  ##########  ##      ########  ##    ##      ######  ##########  ########
########              ##  ##  ##  ##  ##  ##  ##  ##  ##  ##              ########
##########################  ####  ####  ####    ##  ##  ##########################
########          ##            ##    ####  ####            ##  ##  ##  ##########
########      ####  ##  ##      ##    ##  ##        ##  ##########        ########
##########  ##  ####    ##  ######  ##    ######    ######    ##        ##########
##################  ####    ##########    ####      ##      ####        ##########
########  ##  ######  ####  ##    ##        ##    ##  ##    ##      ##############
########  ######    ##  ############  ########  ##  ##  ##      ##    ##  ########
########    ##    ##    ####  ####      ##########    ######    ####    ##########
########  ########  ####    ########  ######  ##    ##      ##  ##    ############
########  ####            ##    ##      ##    ######  ##  ######  ################
########    ##  ########          ######    ##    ####  ####  ########    ########
############          ##    ####  ##      ##########  ########  ####    ##########
########  ##      ####            ####  ########      ##  ##########  ############
############    ##      ####  ####  ####    ##  ####  ##    ####    ##  ##########
########      ####  ##          ##############    ####  ##############    ########
########  ####  ####    ##########            ####    ##      ##  ####  ##########
########  ####  ##  ##  ##############    ##  ##              ##  ##      ########
########  ####  ####    ##    ##        ##  ####  ##              ####    ########
########################    ##  ##  ####  ####      ##    ######    ####  ########
########              ##  ##  ########  ##    ####  ##    ##  ##    ##  ##########
########  ##########  ######  ######  ########        ##  ######  ##  ##  ########
########  ##      ##  ##    ######              ####  ##          ####    ########
########  ##      ##  ##  ####  ####  ##  ####  ########    ##      ##############
########  ##      ##  ##  ########  ##  ##    ####  ####    ######  ##  ##########
########  ##########  ##    ##    ##  ######                ##  ##    ############
########              ##      ####    ########  ####      ########  ##  ##########
##################################################################################
##################################################################################
##################################################################################
##################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment