authenticator_rs/lib.rs
1//!
2//! # Example
3//! ```rust
4//! use crate::authenticator;
5//! fn main(){
6//! let secret = authenticator::create_secret(32); // create a random secret
7//! let pin_code_rs = authenticator::current_pin_code(secret.as_str(), 6);
8//! match pin_code_rs {
9//! Ok(code) => { println!("Current Pin Code: {}", code) }
10//! Err(e) => { println!("Something has error: {}", e) }
11//! }
12//! }
13//!
14//! ```
15mod authenticator;
16
17#[cfg(test)]
18mod test {
19 use crate::authenticator;
20
21 #[test]
22 fn test_create_secret() {
23 let secret = authenticator::create_secret(32);
24 println!("{:?}", secret.as_str());
25 assert_eq!(secret.len(), 32);
26 }
27
28 #[test]
29 fn test_pin_code() {
30 let pin_code = authenticator::current_pin_code("DGF3J5CSIU2JN6WEHECHIUUCLYHCNYAW", 6);
31 match pin_code {
32 Ok(code) => { println!("Current Pin Code: {}", code) }
33 Err(e) => { println!("Something has error: {}", e) }
34 }
35 }
36}