All Projects β†’ jchambers β†’ Java Otp

jchambers / Java Otp

Licence: mit
A one-time password (HOTP/TOTP) library for Java

Programming Languages

68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Otp

πŸ“± Two-Factor Authentication (2FA) client for Android + Wear OS
Stars: ✭ 155 (-41.51%)
Mutual labels:  2fa, totp, two-factor-authentication, hotp
CrOTP - One Time Passwords for Crystal
Stars: ✭ 62 (-76.6%)
Mutual labels:  totp, hotp, two-factor-authentication, 2fa
πŸ”‘ A small library for generating TOTP and HOTP one-time passwords on iOS.
Stars: ✭ 243 (-8.3%)
Mutual labels:  2fa, totp, two-factor-authentication, hotp
One Time
One Time Password (TOTP and HOTP) library for Clojure. TOTP/HOTP is widely used for Two Factor / Multi Factor Authentication.
Stars: ✭ 129 (-51.32%)
Mutual labels:  2fa, totp, two-factor-authentication, hotp
apache 2fa
Apache two-factor (2FA) authentication with Google Authenticator based on Time-based One-Time Password (TOTP) or HMAC-based one-time password (HOTP) Algorithms.
Stars: ✭ 63 (-76.23%)
Mutual labels:  totp, hotp, two-factor-authentication, 2fa
A small and easy-to-use one-time password generator library for Java according to RFC 4226 (HOTP) and RFC 6238 (TOTP).
Stars: ✭ 107 (-59.62%)
Mutual labels:  totp, hotp, two-factor-authentication, 2fa
A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
Stars: ✭ 664 (+150.57%)
Mutual labels:  totp, hotp, two-factor-authentication, 2fa
A free, secure and open source app for Android to manage your 2-step verification tokens.
Stars: ✭ 2,692 (+915.85%)
Mutual labels:  2fa, totp, hotp
Twofactor totp
πŸ”‘ Second factor TOTP (RFC 6238) provider for Nextcloud
Stars: ✭ 203 (-23.4%)
Mutual labels:  2fa, totp, two-factor-authentication
Go Guardian
Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.
Stars: ✭ 204 (-23.02%)
Mutual labels:  2fa, totp, hotp
πŸ”‘ One Time Password (OTP) / 2FA for Node.js and Browser - Supports HOTP, TOTP and Google Authenticator
Stars: ✭ 916 (+245.66%)
Mutual labels:  2fa, two-factor-authentication, hotp
Enhanced fork of FreeOTP-Android providing a feature-rich 2FA authenticator
Stars: ✭ 223 (-15.85%)
Mutual labels:  2fa, totp, hotp
A highly configurable yet simple to use TOTP based two-factor authentication processing module for SimpleSAMLphp.
Stars: ✭ 16 (-93.96%)
Mutual labels:  totp, two-factor-authentication, 2fa
A Swift library for generating One Time Passwords (OTP)
Stars: ✭ 119 (-55.09%)
Mutual labels:  2fa, totp, hotp
A TouchID-aware 2-factor authenticator for macOS
Stars: ✭ 105 (-60.38%)
Mutual labels:  2fa, totp, two-factor-authentication
Time-Based One-Time Password Code Generator
Stars: ✭ 76 (-71.32%)
Mutual labels:  totp, two-factor-authentication, 2fa
Two Factor Authentication Crystal code implementing the Time-based One-time Password Algorithm
Stars: ✭ 24 (-90.94%)
Mutual labels:  totp, two-factor-authentication, 2fa
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+4086.42%)
Mutual labels:  2fa, totp, two-factor-authentication
Minimal TOTP generator in 20 lines of Python
Stars: ✭ 678 (+155.85%)
Mutual labels:  2fa, totp, hotp
HMAC-based (HOTP) and Time-based (TOTP) One-Time Password manager. Works with Google Authenticator for Two-Factor Authentication.
Stars: ✭ 79 (-70.19%)
Mutual labels:  totp, hotp, two-factor-authentication

Build status Maven Central

java-otp is a Java library for generating HOTP (RFC 4226) or TOTP (RFC 6238) one-time passwords.

Getting java-otp

You can download java-otp as a jar file (it has no dependencies) from the GitHub releases page and add it to your project's classpath. If you're using Maven (or something that understands Maven dependencies) to build your project, you can add java-otp as a dependency:


java-otp works with Java 8 or newer. If you need support for versions of Java older than Java 8, you may try using java-otp v0.1 (although it is no longer supported).


To demonstrate generating one-time passwords, we'll focus on the TOTP algorithm. To create a TOTP generator with a default password length (6 digits), time step (30 seconds), and HMAC algorithm (HMAC-SHA1):

final TimeBasedOneTimePasswordGenerator totp = new TimeBasedOneTimePasswordGenerator();

To actually generate time-based one-time passwords, you'll need a key and a timestamp. Secure key management is beyond the scope of this document; for the purposes of an example, though, we'll generate a random key:

final Key key;
    final KeyGenerator keyGenerator = KeyGenerator.getInstance(totp.getAlgorithm());

    // Key length should match the length of the HMAC output (160 bits for SHA-1, 256 bits
    // for SHA-256, and 512 bits for SHA-512).

    key = keyGenerator.generateKey();

Armed with a key, we can deterministically generate one-time passwords for any timestamp:

final Instant now =;
final Instant later =;

System.out.format("Current password: %06d\n", totp.generateOneTimePassword(key, now));
System.out.format("Future password:  %06d\n", totp.generateOneTimePassword(key, later));

…which produces (for one randomly-generated key):

Current password: 164092
Future password:  046148

License and copyright

java-otp is published under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].