Struct boringauth::oath::TOTPBuilder[][src]

pub struct TOTPBuilder { /* fields omitted */ }

Examples

The following examples uses the same shared secret passed in various forms.

 let key = vec![49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48];
 let mut totp = boringauth::oath::TOTPBuilder::new()
     .key(&key)
     .finalize()
     .unwrap();
 let key_ascii = "12345678901234567890".to_owned();
 let mut totp = boringauth::oath::TOTPBuilder::new()
     .ascii_key(&key_ascii)
     .period(42)
     .finalize();
 let key_hex = "3132333435363738393031323334353637383930".to_owned();
 let mut totp = boringauth::oath::TOTPBuilder::new()
     .hex_key(&key_hex)
     .timestamp(1234567890)
     .finalize();
 let key_base32 = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ".to_owned();
 let mut totp = boringauth::oath::TOTPBuilder::new()
     .base32_key(&key_base32)
     .output_len(8)
     .hash_function(boringauth::oath::HashFunction::Sha256)
     .finalize();

Methods

impl TOTPBuilder
[src]

Generates the base configuration for TOTP code generation.

Sets the shared secret.

Sets the shared secret. This secret is passed as an ASCII string.

Sets the shared secret. This secret is passed as an hexadecimal encoded string.

Sets the shared secret. This secret is passed as a base32 encoded string.

Sets the number of characters for the code. The minimum and maximum values depends the base. Default is 6.

Sets the base used to represents the output code. Default is "0123456789".to_owned().into_bytes().

Sets the hash function. Default is Sha1.

Sets a custom value for the current Unix time instead of the real one.

Sets the number of periods ahead or behind the current one for which the user code will still be considered valid. You should not set a value higher than 2. Default is 0.

Sets the number of periods ahead the current one for which the user code will still be considered valid. You should not set a value higher than 2. Default is 0.

Sets the number of periods behind the current one for which the user code will still be considered valid. You should not set a value higher than 2. Default is 0.

Sets the time step in seconds (X). May not be zero. Default is 30.

Sets the Unix time to start counting time steps (T0). Default is 0.

Returns the finalized TOTP object.

Auto Trait Implementations

impl Send for TOTPBuilder

impl Sync for TOTPBuilder