Code Monkey home page Code Monkey logo

totp-arduino's Introduction

Arduino TOTP Library

Library to generate Time-based One-Time Passwords.

Implements the Time-based One-Time Password algorithm specified in RFC 6238. Supports different time steps and it's compatible with tokens that uses the same standard (including software ones, like the Google Authenticator app).

Installation & usage:

Install the library using the Library Manager or manually in the \libraries folder of your IDE. This library requires the Cryptosuite library by maniacbug.

First, store your private key into an array:

uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72};

Then create a new instance of the TOTP class using one of the two available constructors:

TOTP(uint8_t* hmacKey, int keyLength);
TOTP(uint8_t* hmacKey, int keyLength, int timeStep);

The first assumes a timeStep of 30 seconds, value used for example by the Google Authenticator app.

Two methods are available to get a TOTP passcode:

char* getCode(long timeStamp);
char* getCodeFromSteps(long steps);

The first accept a unix timestamp (number of seconds since Epoch), the second the number of "steps" since Epoch (that is seconds / timeStep) and it's useful to get a pool of values.

A demo project:

http://www.lucadentella.it/2013/09/14/serratura-otp/

Thanks to:

totp-arduino's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.