QR Code for Wifi Network Credentials
I’m aware that some places now have QR codes containing the wifi SSID and password, which is clearly far more convenient than having to enter them manually. I’ve not actually found any places near me doing this, and I was curious as to how it works. But googling for information just returns page after page of “QR Code Generator” websites that give no information but offer to generate a QR code for you, if you enter your wifi credentials… like I’m going to just put my wifi creds into a site that gives no information about what it’s doing with it!
So after doing enough digging to satisfy my curiosity I decided to write this blog post, which is simply documentation of what I found, in case it helps someone else in the future looking for the same information.
The data contained within the Wifi QR code is based very closely on the MECARD format used to convey contact information via a QR code. Like MECARD, it’s a CSV-like set of key-value pairs, terminating fields with semi-colons and using colons to separate keys from values, and terminates the entire string with a double semi-colon, but rather than beginning the string with MECARD it begins with WIFI.
An example would be:
WIFI:S:MyFunkyNetwork;T:WPA;P:AComplexPassword;H:;;
In this example, the SSID (indicated with ‘S’) is MyFunkyNetwork
, and the password (indicated with ‘P’) is AComplexPassword
. There are two other possible options, T represents the type of encryption used, and can be either WPA
, WEP
or nopass
. The H indicated whether the network is ‘hidden’ or not (ie if it is broadcasting its SSID it is not hidden) and can be either blank for not hidden, or the string true
if the network is hidden. Some (but not all) of the generators with which I’ve experimented omit this entirely if the network is not hidden, but your mileage may vary.
One other thing: if an SSID or password contains a colon or semi-colon, this can be escaped with a backslash character, but again I’m not sure how much support is available for this, as not all of the generators I’ve found do this. I guess if you really want to be safe, just don’t have those characters in your passwords, but I realise that’s not ideal.
The final step is obviously to generate the QR code containing this text. If you’ve got this far you probably already have a method of doing this, but qrencode
can be installed using apt-get
(or most other package managers), and is relatively straightforward to use.