[−]Struct google_authenticator::GA_AUTH
Methods from Deref<Target = GoogleAuthenticator>
pub fn create_secret(&self, length: u8) -> String
[src]
Create new secret. characters, randomly chosen from the allowed base32 characters.
Example:
use google_authenticator::GoogleAuthenticator; let google_authenticator = GoogleAuthenticator::new(); google_authenticator.create_secret(32);
pub fn get_code(
&self,
secret: &str,
times_slice: i64
) -> Result<String, GAError>
[src]
&self,
secret: &str,
times_slice: i64
) -> Result<String, GAError>
Calculate the code, with given secret and point in time.
Example:
use google_authenticator::GoogleAuthenticator; let google_authenticator = GoogleAuthenticator::new(); google_authenticator.get_code("I3VFM3JKMNDJCDH5BMBEEQAW6KJ6NOE3", 1523610659 / 30).unwrap();
secret : user secret, it will verify each user. times_slice : unix_timestamp / 30 ,if give 0, it will system unix_timestamp
pub fn verify_code(
&self,
secret: &str,
code: &str,
discrepancy: i64,
time_slice: i64
) -> bool
[src]
&self,
secret: &str,
code: &str,
discrepancy: i64,
time_slice: i64
) -> bool
Check if the code is correct.
secret
use for verify user
code
the code to verify
discrepancy
This will accept codes starting from discrepancy*30sec ago to discrepancy*30sec from now.
time_slice
if give 0, it will system unix_timestamp
use google_authenticator::GoogleAuthenticator; let google_authenticator = GoogleAuthenticator::new(); google_authenticator.verify_code("I3VFM3JKMNDJCDH5BMBEEQAW6KJ6NOE3", "224124", 3, 1523610659 / 30);
pub fn qr_code_url(
&self,
secret: &str,
name: &str,
title: &str,
width: u16,
height: u16,
level: char
) -> String
[src]
&self,
secret: &str,
name: &str,
title: &str,
width: u16,
height: u16,
level: char
) -> String
Get QR-Code URL for image, from google charts. width: width of the qrcode. default value 200 px height: height of the qrcode. default value 200 px level: the qrcode level ,it will be L,M,Q,H. Default value is M
Trait Implementations
impl Deref for GA_AUTH
type Target = GoogleAuthenticator
The resulting type after dereferencing.
fn deref(&self) -> &GoogleAuthenticator
impl LazyStatic for GA_AUTH
fn initialize(lazy: &Self)
Auto Trait Implementations
impl RefUnwindSafe for GA_AUTH
impl Send for GA_AUTH
impl Sync for GA_AUTH
impl Unpin for GA_AUTH
impl UnwindSafe for GA_AUTH
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,
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.
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,