[−][src]Struct boringauth::oath::HOTP
Methods
impl HOTP
[src]
pub fn generate(&self) -> String
[src]
Generate the HOTP value.
Examples
let key_ascii = "12345678901234567890".to_owned(); let mut hotp = boringauth::oath::HOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let code = hotp.generate(); assert_eq!(code, "755224"); let code = hotp.increment_counter().generate(); assert_eq!(code, "287082");
pub fn increment_counter(&mut self) -> &mut HOTP
[src]
Increments the internal counter.
pub fn is_valid(&self, code: &String) -> bool
[src]
Checks if the given code is valid. This implementation uses the double HMAC verification in order to prevent a timing side channel attack.
Examples
let key_ascii = "12345678901234567890".to_owned(); let user_code = "755224".to_owned(); let valid = boringauth::oath::HOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap() .is_valid(&user_code); assert_eq!(valid, true);
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,