qrcode for two factor authentication https://gitlab.com/Pacodastre/qrcode
Go to file
Michael Bruderer 74b901cc7f Code cosmetics
2017-10-04 10:30:56 +02:00
ebin Version bump to 1.0.3 2015-12-24 06:53:07 -06:00
src Removed warnings 2016-03-28 23:46:09 +01:00
.gitignore Commit of qrcode encoder and supporting modules. 2011-04-10 23:08:14 -05:00
Emakefile Commit of qrcode encoder and supporting modules. 2011-04-10 23:08:14 -05:00
LICENSE Commit of qrcode encoder and supporting modules. 2011-04-10 23:08:14 -05:00
Makefile New makefile try 2016-02-24 23:47:26 +00:00
mix.exs Code cosmetics 2017-10-04 10:30:56 +02:00
README.markdown Updated elixir documentation 2016-02-25 00:58:50 +00:00

QR Code Encoder

Reference used was ISO/IEC 18004, 1st Edition (2000)

This implementation is informed by my specific needs, i.e. to provide two-factor authentication for mobile phones running Google Authenticator.

  • "Byte" mode only (don't need e.g. numeric mode or kanji mode).
  • Encode only (no detection/decode).
  • Basic supporting library functions provided (HOTP, PNG image functions) to allow full-cyle demo.

Demo

  1. Download repo and compile with erl -make
  2. Install Google Authenticator App on your mobile:
  3. Run demo: qrcode_demo:run().
  4. Open the generated qrcode.png file
  5. Scan the qrcode into the phone.
  6. Ensure server clock is correct.
  7. The value of qrcode_demo:totp() should show the same passcode as the phone.
  8. Handle PINs/logins for the second part of the "two factor" according to your application design.

NOTE: This documentation is rather basic as this was open-sourced by specific request!

How to use QR Code Encoder with Elixir

Add :qrcode to mix.deps ::

defp deps do
  [{:qrcode, git: “git@gitlab.com:Pacodastre/qrcode.git”}]
end

Then run: ::

mix deps.get
mix deps.compile

Then, whenever you have this compiled, you should have access to the functions available in elixir.

iex(1)> qrcode = :qrcode.encode(“bla”)
{:qrcode, 1, :M, 29,
 <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 211, 248, 4, 16, 208, 64, 46, 152, ...>>}
 iex(2)> png = :qrcode_demo.simple_png_encode(qrcode)
 <<137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 232, 0, 0, 0, ...>>
 iex(3)> :file.write_file(“example.png”, png)
 :ok