Struct authenticator::models::otp::OTP
source · pub struct OTP {
secret: Vec<u8>,
algorithm: Algorithm,
digits: u32,
}
Fields§
§secret: Vec<u8>
§algorithm: Algorithm
§digits: u32
Implementations§
source§impl OTP
impl OTP
const STEAM_CHARS: &'static str = "23456789BCDFGHJKMNPQRTVWXY"
pub const STEAM_DEFAULT_PERIOD: u32 = 30u32
pub const STEAM_DEFAULT_DIGITS: u32 = 5u32
pub const DEFAULT_COUNTER: u32 = 1u32
pub const DEFAULT_DIGITS: u32 = 6u32
pub const DEFAULT_PERIOD: u32 = 30u32
pub fn is_valid(secret: &str) -> bool
fn time_based_counter(period: u32) -> u64
pub fn from_bytes_steam(secret: impl AsRef<[u8]>) -> Self
pub fn from_str_steam(secret: &str) -> Result<Self>
pub fn from_str_with_defaults(secret: &str) -> Result<Self>
pub fn from_str(secret: &str, algorithm: Algorithm, digits: u32) -> Result<Self>
pub fn from_bytes_with_defaults(secret: impl AsRef<[u8]>) -> Self
pub fn from_bytes( secret: impl AsRef<[u8]>, algorithm: Algorithm, digits: u32 ) -> Self
sourcepub fn hotp(&self, counter: u64) -> Result<u32>
pub fn hotp(&self, counter: u64) -> Result<u32>
Performs the HMAC-based One-time Password Algorithm (HOTP) given an RFC4648 base32 encoded secret, and an integer counter.
pub fn hotp_formatted(&self, counter: u64) -> Result<String>
pub fn totp(&self, period: Option<u32>) -> Result<u32>
pub fn totp_formatted(&self, period: Option<u32>) -> Result<String>
pub fn steam(&self, counter: Option<u64>) -> Result<String>
pub fn secret(&self) -> String
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for OTP
impl Send for OTP
impl Sync for OTP
impl Unpin for OTP
impl UnwindSafe for OTP
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