Skip to content

Commit 7ad126a

Browse files
authored
Merge pull request #3 from revathskumar/fix/make-case-insensitive
Fixes #1: fix showing only 5 chars when OTP starts with 0.
2 parents 2a9bd07 + 18e0854 commit 7ad126a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
## 0.3.1
1515

1616
- default will be case insensitive search. Use `grave` key to toggle.
17+
18+
## 0.3.2
19+
20+
- Fixes #1: fix showing only 5 chars when OTP starts with 0.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rofi-totp"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
authors = ["Revath S Kumar <rsk@revathskumar.com>"]
55
documentation = "https://github.com/revathskumar/rofi-totp"
66
homepage = "https://github.com/revathskumar/rofi-totp"

src/totp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ extern crate oath;
33

44
// use oath::totp;
55

6-
pub fn generate(secret: &str) -> Result<u64, &'static str> {
6+
pub fn generate(secret: &str) -> Result<String, &'static str> {
77
let secret_bytes = try!(base32::decode(base32::Alphabet::RFC4648 {padding: false}, &secret.replace(" ", "")).ok_or("invalid base32"));
8-
let code: u64 = oath::totp_raw_now(&secret_bytes, 6, 0, 30, &oath::HashType::SHA1);
9-
Ok(code)
8+
let code: String = oath::totp_raw_now(&secret_bytes, 6, 0, 30, &oath::HashType::SHA1).to_string();
9+
Ok(format!("{:0>6}", code))
1010
}

0 commit comments

Comments
 (0)