Skip to content

A minimal implementation of the TOTP and HOTP algorithms.

License

Notifications You must be signed in to change notification settings

itsadrake/simpleTOTPd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simpleTOTPd

A minimal implementation of the TOTP and HOTP algorithms (based on simpleTOTP).

Dependencies

  • A D compiler (tested with DMD64 v2.070.0)
  • DUB

Building

Run dub to compile libsimpleTOTPd.a, and dub test run a simple test suite. Intended to be used as a DUB dependency.

Using

The modules simpletotp.totp and simpletotp.hotp are available for your importing pleasure. The functions you can use are the following:

int totp(const ubyte[] key, const ulong time, const int offset = 0, const int digits = 6);

Calculates the TOTP token for key at given time plus offset times interval (30s), truncated to digits digits.

int hotp(const ubyte[] key, const ulong counter, const int digits = 6);

Calculates the HOTP token for key with given counter, truncated to digits digits.

bool verify_token(const ubyte[] key, const int token, const int sync);

Returns true if the TOTP token for key at current time (± sync times interval) matches token, false otherwise.

Licence

MIT, see LICENCE file for full text.

About

A minimal implementation of the TOTP and HOTP algorithms.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages