pub struct HOTP { /* private fields */ }Expand description
HMAC-based One-Time Password (HOTP) generator.
Implements RFC 4226.
Implementations§
Source§impl HOTP
impl HOTP
Sourcepub fn builder() -> HOTPBuilder
pub fn builder() -> HOTPBuilder
Returns a new HOTP builder
Sourcepub fn new(secret: Vec<u8>, algorithm: Algorithm, digits: u32) -> Self
pub fn new(secret: Vec<u8>, algorithm: Algorithm, digits: u32) -> Self
Creates a new HOTP instance with the given secret, algorithm, and digits
Sourcepub fn generate(&self, counter: u64) -> u32
pub fn generate(&self, counter: u64) -> u32
Generates the HOTP value for the given counter as an integer
Sourcepub fn generate_formatted(&self, counter: u64) -> String
pub fn generate_formatted(&self, counter: u64) -> String
Generates the HOTP value as a formatted string with leading zeros
Sourcepub fn verify(&self, code: u32, counter: u64) -> bool
pub fn verify(&self, code: u32, counter: u64) -> bool
Verifies an HOTP value for the given counter
Sourcepub fn verify_formatted(&self, code: &str, counter: u64) -> bool
pub fn verify_formatted(&self, code: &str, counter: u64) -> bool
Verifies a formatted HOTP string for the given counter
Trait Implementations§
Auto Trait Implementations§
impl Forget for HOTP
impl Freeze for HOTP
impl Move for HOTP
impl RefUnwindSafe for HOTP
impl Send for HOTP
impl Sync for HOTP
impl Unpin for HOTP
impl UnsafeUnpin for HOTP
impl UnwindSafe for HOTP
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