Expand description
§lib2fas
lib2fas is a comprehensive library for managing and processing two-factor authentication (2FA) services.
It provides tools for securely decrypting, organizing, and interacting with 2FA data in various formats,
along with utilities for fuzzy matching, JSON5 parsing, and more.
§Features
- Secure Decryption: Support for AES-256-GCM decryption using PBKDF2.
- 2FA Data Management: Provides data structures to represent and query OTPs, 2FA services, and storage.
- Fuzzy Matching: Functions for string similarity comparisons, useful for searching and filtering.
- JSON5 Support: Utilities for parsing and serializing JSON5 configurations, synchronously and asynchronously.
- Helper Utilities: Common functions and abstractions for efficient processing.
§Example
Here’s a quick example of loading and working with 2FA services:
use lib2fas::load_services;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let result = load_services("path/to/services.2fas", Some("passphrase")).await;
match result {
Ok(storage) => {
println!("Loaded {} services", storage.len());
if let Some(service) = storage.first() {
println!("First service: {}", service.name);
if let Some(otp) = service.totp() {
println!("Current OTP: {}", otp);
} else {
println!("OTP generation not available for this service.");
}
} else {
println!("No services found.");
}
},
Err(err) => {
eprintln!("Failed to load services: {}", err);
},
}
Ok(())
}§Modules
decrypt: Functions for securely decrypting 2FA data.fuzzy: Utilities for fuzzy string matching.helpers: Common helper functions.json5_support: Support for JSON5 parsing and serialization.lib2fas: Core components and types for managing 2FA services.
§Re-Exports
load_services: Main entry point for loading 2FA services.OTPDetails: Details and functionality for one-time passwords.TwoFactorAuthDetails: Represents a single 2FA service.TwoFactorStorage: Manages and queries multiple 2FA services.
Re-exports§
pub use crate::lib2fas::load_services;pub use crate::lib2fas::OTPDetails;pub use crate::lib2fas::TwoFactorAuthDetails;pub use crate::lib2fas::TwoFactorStorage;
Modules§
- Provides functionality for decrypting data, including AES-256-GCM decryption with PBKDF2.
- Contains utilities for fuzzy string matching and similarity calculations.
- Offers helper functions and utilities used across the library.
- Provides support for working with JSON5 format, including serialization and deserialization.
- Defines the core types, traits, and functions of the
lib2faslibrary.