#totp #hotp #otp #authenticator

otps

Out-of-box HOTP and TOTP client to generate one-time password

2 releases

0.1.1 Nov 12, 2023
0.1.0 Nov 12, 2023

#759 in Authentication

22 downloads per month

MIT license

9KB
149 lines

otps

Crates.io Tests status docs.rs

This package is a library designed to provide out-of-box HOTP and TOTP clients to generate one-time passwords.

Features

  • HOTP and TOTP implementations are based on RFC4226 and RFC6238
  • Built-in base32 secret decoding

Installation

cargo add otps

Getting started

use otps::TotpBuilder;

let mut totp_cleint = TotpBuilder::new()
  .base32_secret("GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ")
  .build()
  .expect("failed to initialize TOTP client");

let totp_code = totp_cleint.generate();

println!("TOTP: {}", totp_code); // 123456

For more examples and detailed usage, refer to the online documentation.

Contributions

Contributions to this project are welcome and encouraged. If you encounter any bugs or issues, please open an issue on the GitHub repository. If you would like to contribute to the project, please fork the repository and submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Dependencies

~7–16MB
~284K SLoC