| Crates.io | vortex-otp-lib |
| lib.rs | vortex-otp-lib |
| version | 0.1.4 |
| created_at | 2025-05-07 07:06:50.566537+00 |
| updated_at | 2025-05-07 07:12:48.659518+00 |
| description | A flexible One-Time Password (OTP) generation library for Rust. |
| homepage | |
| repository | https://github.com/c4nzin/vortex-otp-rust |
| max_upload_size | |
| id | 1663555 |
| size | 11,922 |
VortexOTP is a simple, flexible, and dependency-light One-Time Password (OTP) generation library for Rust. It allows you to generate OTPs of various lengths and character sets, including numeric, alphanumeric, alphanumeric with special characters, or even your own custom character sets.
rand).Add VortexOTP to your Cargo.toml:
[dependencies]
VortexOTP = "0.1.4"
Or, if you are using it from a local path or git repository:
Here's a quick example of how to use VortexOTP:
use vortex_otp_lib::{generate_otp, OtpCharSet};
fn main() {
let otp = generate_otp(6,OtpCharSet::Alphanumeric);
println!("OTP: {:?}", otp);
match generate_otp(6, OtpCharSet::Numeric) {
Ok(otp) => println!("Numeric OTP: {:?}", otp),
Err(e) => eprintln!("Error: {}", e),
}
match generate_otp(8, OtpCharSet::Alphanumeric) {
Ok(otp) => println!("Alphanumeric OTP: {:?}", otp),
Err(e) => eprintln!("Error: {}", e),
}
match generate_otp(10, OtpCharSet::AlphanumericSpecialChars) {
Ok(otp) => println!("Alphanumeric Special OTP: {:?}", otp),
Err(e) => eprintln!("Error: {}", e),
}
let custom_chars = "ABCDEF123456!@#".to_string();
match generate_otp(7, OtpCharSet::Custom(custom_chars)) {
Ok(otp) => println!("Custom OTP: {:?}", otp),
Err(e) => eprintln!("Error: {}", e),
}
match generate_otp(5, OtpCharSet::Custom("".to_string())) {
Ok(otp) => println!("This won't print: {:?}", otp),
Err(e) => eprintln!("Error generating custom OTP: {}", e),
}
}
OtpCharSet::Numeric: 0123456789OtpCharSet::Alphanumeric: 0-9, a-z, A-ZOtpCharSet::AlphanumericSpecialChars: 0-9, a-z, A-Z, !@#$%^&*()_+-=[]{}|;:,.<>?OtpCharSet::Custom(String): Any String you provide.Contributions are welcome! Please feel free to submit a pull request or open an issue.
VortexOTP is licensed under the MIT License. See the LICENSE file (you would need to create this file if you choose MIT and want to include the full license text) in the repository for more details.