Struct google_authenticator::google_authenticator::GoogleAuthenticator [] [src]

pub struct GoogleAuthenticator { /* fields omitted */ }

Methods

impl GoogleAuthenticator
[src]

[src]

[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);

[src]

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

[src]

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).unwrap();

Trait Implementations

Auto Trait Implementations