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]
impl TOTPBuilder
pub fn new() -> TOTPBuilder
[src]
pub fn new() -> TOTPBuilder
Generates the base configuration for TOTP code generation.
pub fn key(&mut self, key: &Vec<u8>) -> &mut TOTPBuilder
[src]
pub fn key(&mut self, key: &Vec<u8>) -> &mut TOTPBuilder
Sets the shared secret.
pub fn ascii_key(&mut self, key: &String) -> &mut TOTPBuilder
[src]
pub fn ascii_key(&mut self, key: &String) -> &mut TOTPBuilder
Sets the shared secret. This secret is passed as an ASCII string.
pub fn hex_key(&mut self, key: &String) -> &mut TOTPBuilder
[src]
pub fn hex_key(&mut self, key: &String) -> &mut TOTPBuilder
Sets the shared secret. This secret is passed as an hexadecimal encoded string.
pub fn base32_key(&mut self, key: &String) -> &mut TOTPBuilder
[src]
pub fn base32_key(&mut self, key: &String) -> &mut TOTPBuilder
Sets the shared secret. This secret is passed as a base32 encoded string.
pub fn output_len(&mut self, output_len: usize) -> &mut TOTPBuilder
[src]
pub fn output_len(&mut self, output_len: usize) -> &mut TOTPBuilder
Sets the number of characters for the code. The minimum and maximum values depends the base. Default is 6.
pub fn output_base(&mut self, base: &Vec<u8>) -> &mut TOTPBuilder
[src]
pub fn output_base(&mut self, base: &Vec<u8>) -> &mut TOTPBuilder
Sets the base used to represents the output code. Default is "0123456789".to_owned().into_bytes().
pub fn hash_function(&mut self, hash_function: HashFunction) -> &mut TOTPBuilder
[src]
pub fn hash_function(&mut self, hash_function: HashFunction) -> &mut TOTPBuilder
Sets the hash function. Default is Sha1.
pub fn timestamp(&mut self, timestamp: i64) -> &mut TOTPBuilder
[src]
pub fn timestamp(&mut self, timestamp: i64) -> &mut TOTPBuilder
Sets a custom value for the current Unix time instead of the real one.
pub fn tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
[src]
pub fn tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
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.
pub fn positive_tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
[src]
pub fn positive_tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
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.
pub fn negative_tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
[src]
pub fn negative_tolerance(&mut self, tolerance: u64) -> &mut TOTPBuilder
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.
pub fn period(&mut self, period: u32) -> &mut TOTPBuilder
[src]
pub fn period(&mut self, period: u32) -> &mut TOTPBuilder
Sets the time step in seconds (X). May not be zero. Default is 30.
pub fn initial_time(&mut self, initial_time: u64) -> &mut TOTPBuilder
[src]
pub fn initial_time(&mut self, initial_time: u64) -> &mut TOTPBuilder
Sets the Unix time to start counting time steps (T0). Default is 0.
pub fn finalize(&self) -> Result<TOTP, ErrorCode>
[src]
pub fn finalize(&self) -> Result<TOTP, ErrorCode>
Returns the finalized TOTP object.
Auto Trait Implementations
impl Send for TOTPBuilder
impl Send for TOTPBuilder
impl Sync for TOTPBuilder
impl Sync for TOTPBuilder