pub struct TOTP { /* private fields */ }Expand description
TOTP generator and validator.
Secret is securely zeroized from memory when dropped.
Implementations§
Source§impl TOTP
impl TOTP
Sourcepub fn with_secret(secret: Vec<u8>) -> Self
pub fn with_secret(secret: Vec<u8>) -> Self
Create with default settings (6 digits, 30 second interval).
Sourcepub fn generate_secret() -> Result<Vec<u8>>
pub fn generate_secret() -> Result<Vec<u8>>
Generate a random secret.
Sourcepub fn verify(&self, code: &str, timestamp: Option<u64>, window: u32) -> bool
pub fn verify(&self, code: &str, timestamp: Option<u64>, window: u32) -> bool
Verify TOTP code with time window.
Sourcepub fn secret_to_base32(secret: &[u8]) -> String
pub fn secret_to_base32(secret: &[u8]) -> String
Convert secret to Base32.
Sourcepub fn provisioning_uri(&self, account: &str, issuer: &str) -> String
pub fn provisioning_uri(&self, account: &str, issuer: &str) -> String
Generate provisioning URI for QR codes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TOTP
impl RefUnwindSafe for TOTP
impl Send for TOTP
impl Sync for TOTP
impl Unpin for TOTP
impl UnsafeUnpin for TOTP
impl UnwindSafe for TOTP
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more