File tree Expand file tree Collapse file tree 8 files changed +46
-54
lines changed Expand file tree Collapse file tree 8 files changed +46
-54
lines changed Original file line number Diff line number Diff line change
1
+ on : [push, pull_request]
2
+
3
+ name : CI
4
+
5
+ jobs :
6
+ check :
7
+ name : Check
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - uses : actions/checkout@v4
11
+ - uses : dtolnay/rust-toolchain@stable
12
+ - run : cargo check
13
+
14
+ test :
15
+ name : Test Suite
16
+ runs-on : ${{ matrix.os }}
17
+ strategy :
18
+ matrix :
19
+ os : [ubuntu-latest, macos-latest, windows-latest]
20
+ steps :
21
+ - uses : actions/checkout@v4
22
+ - uses : dtolnay/rust-toolchain@stable
23
+ - run : cargo test
24
+
25
+ fmt :
26
+ name : Rustfmt
27
+ runs-on : ubuntu-latest
28
+ steps :
29
+ - uses : actions/checkout@v4
30
+ - uses : dtolnay/rust-toolchain@stable
31
+ with :
32
+ components : rustfmt
33
+ - run : cargo fmt --all -- --check
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,11 +9,8 @@ name = "otpauth"
9
9
readme = " README.md"
10
10
repository = " https://github.com/messense/otpauth-rs"
11
11
version = " 0.4.1"
12
- edition = " 2018 "
12
+ edition = " 2021 "
13
13
14
14
[dependencies ]
15
15
base32 = " 0.5.1"
16
16
ring = " 0.17.8"
17
-
18
- [features ]
19
- unstable = []
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
//! # Example
4
4
//!
5
5
//! ```
6
- //! extern crate otpauth;
7
- //!
8
6
//! fn main() {
9
7
//! let auth = otpauth::HOTP::new("python");
10
8
//! let code = auth.generate(4);
11
9
//! assert!(auth.verify(code, 0, 100));
12
10
//! }
13
11
//! ```
14
12
15
- use std:: convert:: TryInto ;
16
-
17
13
use base32:: Alphabet :: Rfc4648 ;
18
14
use ring:: hmac;
19
15
@@ -40,7 +36,9 @@ impl HOTP {
40
36
/// Constructs a new `HOTP` with secret bytes
41
37
#[ must_use]
42
38
pub fn from_bytes ( bytes : & [ u8 ] ) -> HOTP {
43
- HOTP { secret : bytes. into ( ) }
39
+ HOTP {
40
+ secret : bytes. into ( ) ,
41
+ }
44
42
}
45
43
46
44
/// Generate a HOTP code.
Original file line number Diff line number Diff line change 6
6
//!
7
7
//! ```toml
8
8
//! [dependencies]
9
- //! otpauth = "0.3 "
9
+ //! otpauth = "0.4 "
10
10
//! ```
11
11
//!
12
12
//! # Examples
13
13
//!
14
14
//! ## HOTP example
15
15
//!
16
16
//! ```rust
17
- //! extern crate otpauth;
18
- //!
19
17
//! use otpauth::HOTP;
20
18
//!
21
19
//! let auth = HOTP::new("python");
Original file line number Diff line number Diff line change @@ -12,9 +12,15 @@ fn test_hotp() {
12
12
#[ test]
13
13
fn test_totp ( ) {
14
14
let auth = otpauth:: TOTP :: new ( "python" ) ;
15
- let timestamp1 = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) . as_secs ( ) ;
15
+ let timestamp1 = SystemTime :: now ( )
16
+ . duration_since ( UNIX_EPOCH )
17
+ . unwrap ( )
18
+ . as_secs ( ) ;
16
19
let code = auth. generate ( 30 , timestamp1) ;
17
- let timestamp2 = SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . unwrap ( ) . as_secs ( ) ;
20
+ let timestamp2 = SystemTime :: now ( )
21
+ . duration_since ( UNIX_EPOCH )
22
+ . unwrap ( )
23
+ . as_secs ( ) ;
18
24
assert ! ( auth. verify( code, 30 , timestamp2) ) ;
19
25
assert ! ( !auth. verify( 123456 , 30 , timestamp2) ) ;
20
26
assert ! ( !auth. verify( 1234567 , 30 , timestamp2) ) ;
You can’t perform that action at this time.
0 commit comments