Struct otpshka::TOTP [−][src]
Modification of Htop
algorithm that uses unix timestamp within window
Fields
skew: u8
Number of seconds allowed as network delay.
Default and recommended is 1.
window: u64
Time window in seconds.
Default and recommended is 30.
Implementations
impl TOTP
[src]
pub fn new<T: AsRef<[u8]>>(algorithm: Algorithm, secret: T) -> Self
[src]
Initializes algorithm using provided algorithm
and secret
algorithm
- Generally acceptable are HMAC based onsha-1
,sha-256
andsha-512
secret
- Raw bytes used to derive HMAC key. User is responsible to decode it before passing.
pub fn sign(&self, time: u64) -> impl AsRef<[u8]> + Clone + Copy
[src]
Signs provided time
value using stored HMAC key.
pub fn generate_num(&self, time: u64, digits: u8) -> u32
[src]
Generates password as number from provided counter
value with length of digits
.
Note that in this case you must handle missing padding yourself.
pub fn generate_to<T: AsMut<[u8]>>(&self, time: u64, dest: T)
[src]
Generates pass based on provided time
and writes it into provided dest
.
This always writes dest.as_ref().len()
.
Recommended buffer length is be within 6..8
pub fn generate_to_now<T: AsMut<[u8]>>(&self, dest: T)
[src]
Generates pass using current system time from std
pub fn verify(&self, token: &str, time: u64) -> bool
[src]
Checks whether provided token
corresponds to time
.
pub fn verify_now(&self, token: &str) -> bool
[src]
Checks whether provided token
corresponds to current system time.
Auto Trait Implementations
impl RefUnwindSafe for TOTP
impl Send for TOTP
impl Sync for TOTP
impl Unpin for TOTP
impl UnwindSafe for TOTP
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
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.
pub 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>,