Skip to content

CarlosHe/otp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time-based one-time password

A Delphi library for generating one-time passwords according to RFC 4226 (HOTP Algorithm) and RFC 6238 (TOTP Algorithm).

⚙️ Installation

Installation is done using the boss install command:

boss install https://github.com/CarlosHe/otp

⚡️ Generate a new secret

uses
  OTP;

var
  LSecret: string;
begin
  LSecret := TOTPSecretGenerator.New
    .SetKeyLength(10)
    .Generate;
end.

⚡️ Generate a new token

uses
  OTP;

var
  LToken: UInt32;
begin
  LToken := TOTPCalculator.New
    .SetSecret('MYSECRETBASE32')
    .Calculate;
end.

⚡️ Validate a token

uses
  OTP;

begin
  TOTPValidator.New(
    TOTPCalculator
      .New
      .SetSecret('MYSECRETBASE32')
  )
  .SetToken(102030)
  .Validate;
end.

About

Time-based one-time password for Delphi

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages