Skip to content

Elon2point0/totp-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOTP Library 📚🔐

TOTP Library Version

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.

Table of Contents

Introduction

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.

Features

  • Simple and clean API
  • Written in Rust for performance
  • Supports WebAssembly (WASM)
  • Easy to integrate into existing applications
  • Well-documented codebase

Getting Started

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.

Usage

After downloading, you can easily integrate the TOTP Library into your Rust application. The library provides essential functions to generate and verify TOTP codes.

Installation

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

Example

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.

Contributing

We welcome contributions to improve the TOTP Library. If you have ideas, bug fixes, or enhancements, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature/YourFeature).
  6. Open a pull request.

Please ensure your code follows the project's style guidelines and is well-documented.

License

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

Contact

For any questions or feedback, feel free to reach out:

Thank you for checking out the TOTP Library! For the latest updates, visit our Releases section.

Happy coding! 🎉