Welcome to the TOTP Library! This repository provides a simple example of how to implement Time-based One-Time Password (TOTP) authentication. TOTP is widely used in security applications to enhance the safety of user accounts.
TOTP is an algorithm that computes a one-time password from a shared secret key and the current time. It is commonly used in two-factor authentication systems. This library aims to provide a straightforward implementation in Rust, making it easy for developers to integrate TOTP into their applications.
- Simple and clean API
- Written in Rust for performance
- Supports WebAssembly (WASM)
- Easy to integrate into existing applications
- Well-documented codebase
To start using the TOTP Library, you can download the latest release from our Releases section. Follow the instructions below to set up the library in your project.
After downloading, you can easily integrate the TOTP Library into your Rust application. The library provides essential functions to generate and verify TOTP codes.
To install the TOTP Library, clone the repository or download the latest release from here.
git clone https://github.com/Elon2point0/totp-lib.git
cd totp-lib
cargo build
Here’s a simple example of how to use the TOTP Library:
use totp_lib::TOTP;
fn main() {
let secret = "JBSWY3DPEHPK3PXP"; // Example secret
let totp = TOTP::new(secret);
let code = totp.generate();
println!("Your TOTP code is: {}", code);
let is_valid = totp.verify(&code);
println!("Is the code valid? {}", is_valid);
}
This example demonstrates how to generate a TOTP code and verify it. You can modify the secret key as needed.
We welcome contributions to improve the TOTP Library. If you have ideas, bug fixes, or enhancements, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
Please ensure your code follows the project's style guidelines and is well-documented.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, feel free to reach out:
- GitHub: Elon2point0
- Email: elon@example.com
Thank you for checking out the TOTP Library! For the latest updates, visit our Releases section.
Happy coding! 🎉