[−][src]Struct boringauth::oath::HOTPBuilder
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 hotp = boringauth::oath::HOTPBuilder::new() .key(&key) .finalize() .unwrap();
let key_ascii = "12345678901234567890".to_owned(); let mut hotp = boringauth::oath::HOTPBuilder::new() .ascii_key(&key_ascii) .counter(42) .finalize() .unwrap();
let key_hex = "3132333435363738393031323334353637383930".to_owned(); let mut hotp = boringauth::oath::HOTPBuilder::new() .hex_key(&key_hex) .counter(69) .output_len(8) .finalize();
let key_base32 = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ".to_owned(); let mut hotp = boringauth::oath::HOTPBuilder::new() .base32_key(&key_base32) .output_len(8) .hash_function(boringauth::oath::HashFunction::Sha256) .finalize();
Methods
impl HOTPBuilder
[src]
pub fn new() -> HOTPBuilder
[src]
Generates the base configuration for HOTP code generation.
pub fn key(&mut self, key: &Vec<u8>) -> &mut HOTPBuilder
[src]
Sets the shared secret.
pub fn ascii_key(&mut self, key: &String) -> &mut HOTPBuilder
[src]
Sets the shared secret. This secret is passed as an ASCII string.
pub fn hex_key(&mut self, key: &String) -> &mut HOTPBuilder
[src]
Sets the shared secret. This secret is passed as an hexadecimal encoded string.
pub fn base32_key(&mut self, key: &String) -> &mut HOTPBuilder
[src]
Sets the shared secret. This secret is passed as a base32 encoded string.
pub fn output_len(&mut self, output_len: usize) -> &mut HOTPBuilder
[src]
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 HOTPBuilder
[src]
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 HOTPBuilder
[src]
Sets the hash function. Default is Sha1.
pub fn counter(&mut self, counter: u64) -> &mut HOTPBuilder
[src]
Sets the counter. Default is 0.
pub fn finalize(&self) -> Result<HOTP, ErrorCode>
[src]
Returns the finalized HOTP object.
Auto Trait Implementations
impl Send for HOTPBuilder
impl Sync for HOTPBuilder
Blanket Implementations
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<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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,