Transmitting data via QR-code

QR Code for post https://wiesmann.codiferes.net/wordpress/?p=25370

With all the talk about security, it is pretty hard to transfer information from your desktop computer to your laptop, like for instance passing a password from a desktop web application to an app on your phone. Using a password manager like Apple’s keychain helps, but when you have a web app on one side and a native app on the other, things are not so smooth, and you still have to trust that cloud storage’s encryption.

In theory, the solution is simple, generate a QR-code with the password, display it on the computer’s screen, scan it with phone’s camera and copy-paste the password from the QR-code reader to the destination app. To do this, you need the following to pass information from Mac OS X to iOS.

Now you can extract an item from the keychain and generate a qr-code from it (fish shell syntax):

qrencode -t ANSI256 (security find-generic-password -a account -s service -w)

This will look into keychain for service service with user-name account and display the corresponding password inside the terminal using ANSI escape-codes. Yes, we are using technology from the 70’s to generate a code designed in 99 in Japan.

█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ █ ██▀▀ ▄▄▄▀▀▀██ ▄▄▄▄▄ ████
████ █   █ █  ▀█ ▀ ▀▄▄▀█▄█ █   █ ████
████ █▄▄▄█ █▀  █▄▄▀▄▄█▄▀▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█ ▀▄█ ▀ ▀ ▀ █▄▄▄▄▄▄▄████
████▄▄▀▀  ▄▀██▄█▄▀█▀ ▄█▄▄█▀ ▀    ████
████▀█ ▀  ▄ ▄ ▄█▀▄▀ ▄▀▀█▄▄ █▀██▀ ████
████▀▄█▄▄▄▄▀█▀▀▄ █ ▀▀  █▄▄▀▀▀▀█ ▀████
████ ██▄▀ ▄█▀█  ▀▄ ▄ ▀▄█▀▀█▀▄█▄▀ ████
████ ▀▀█▄ ▄▀▀▀ ▄ █▄▀  ▀▄▄▄▀ ▀▄█ ▀████
██████ ▄  ▄▄▄█▀▀ ▄ ▄█▀▄▀ ▀███▄▄▀ ████
████▄▄▄█▄█▄▄▀   █▀█ ▀▄▀▀ ▄▄▄ ▄██ ████
████ ▄▄▄▄▄ █▀██▀▀██▄█    █▄█  ▄█▄████
████ █   █ █▄▀▄█▀█▄▀ ▄█▄▄▄▄▄▄█▀█ ████
████ █▄▄▄█ █▀ █ ██ ▄█ ▄█▀▄███ ▄  ████
████▄▄▄▄▄▄▄█▄▄▄██▄▄▄█▄▄█▄█▄██▄█▄█████
█████████████████████████████████████
█████████████████████████████████████

The security command is pretty interesting and it is certainly worthwhile having a look at its man page, qrencode, the shell wrapper that comes with libqrencode also has interesting options, in particular UTF8 lets you generate a QR-Code as a sequence of Unicode characters, like the example on the side.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.