Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 929 Bytes

README.md

File metadata and controls

30 lines (25 loc) · 929 Bytes

chronometrophobia Build

A Java TOTP library.

Installation

<dependency>
  <groupId>com.aaronbedra</groupId>
  <artifactId>chronometrophobia</artifactId>
  <version>1.0</version>
</dependency>

Usage

public class Main {
    public static void main(String[] args) {
        generateSeed(64)
                .<IO<Seed>>runReaderT(new SecureRandom())
                .zip(now().fmap(tupler()))
                .flatMap(into((timeStamp, seed) -> generateInstance(otp6(), hMacSHA1(), seed, counter(timeStamp, timeStep30()))))
                .flatMap(failureOrTotp -> failureOrTotp.match(
                        hmacFailure -> io(() -> System.out.println(hmacFailure.getValue().getMessage())),
                        totp -> io(() -> System.out.println(totp))))
                .unsafePerformIO();
    }
}