pub struct HOTP { /* private fields */ }
Expand description
Two-step verfication of HOTP algorithm.
Implementations§
Source§impl HOTP
impl HOTP
Sourcepub fn from_base32<S: Into<String>>(secret: S) -> Option<HOTP>
pub fn from_base32<S: Into<String>>(secret: S) -> Option<HOTP>
Constructs a new HOTP
with base-32 encoded secret bytes
Sourcepub fn from_bytes(bytes: &[u8]) -> HOTP
pub fn from_bytes(bytes: &[u8]) -> HOTP
Constructs a new HOTP
with secret bytes
Sourcepub fn generate(&self, counter: u64) -> u32
pub fn generate(&self, counter: u64) -> u32
Generate a HOTP code.
counter
: HOTP is a counter based algorithm.
Sourcepub fn verify(&self, code: u32, last: u64, trials: u64) -> bool
pub fn verify(&self, code: u32, last: u64, trials: u64) -> bool
Valid a HOTP code.
code
: A number that is less than 6 characters.
last
: Guess HOTP code from last + 1
range.
trials
: Guess HOTP code end at last + trials + 1
.
Sourcepub fn base32_secret(&self) -> String
pub fn base32_secret(&self) -> String
Return the secret bytes in base32 encoding.
Trait Implementations§
impl Eq for HOTP
impl StructuralPartialEq for HOTP
Auto Trait Implementations§
impl Freeze for HOTP
impl RefUnwindSafe for HOTP
impl Send for HOTP
impl Sync for HOTP
impl Unpin 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