emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/base32 4595bb3b7c 008/103: Make the returned TOTP token a


From: ELPA Syncer
Subject: [nongnu] elpa/base32 4595bb3b7c 008/103: Make the returned TOTP token a string so we don't lose leading 0s
Date: Sat, 10 Feb 2024 12:59:52 -0500 (EST)

branch: elpa/base32
commit 4595bb3b7cdec81f2e4895beedccd1c2813d043c
Author: Vivek Das Mohapatra <vivek@collabora.co.uk>
Commit: Vivek Das Mohapatra <vivek@collabora.co.uk>

    Make the returned TOTP token a string so we don't lose leading 0s
---
 tests/test-totp.el | 2 +-
 totp.el            | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/test-totp.el b/tests/test-totp.el
index 979084a71b..64a484dd89 100644
--- a/tests/test-totp.el
+++ b/tests/test-totp.el
@@ -109,7 +109,7 @@
         (stamp (format-time-string "%Y-%m-%d %H:%M:%S" totp-override-time t))
         have)
     (dolist (otp generated-otp)
-      (setq have (car otp))
+      (setq have (string-to-number (car otp)))
       (or (equal want have)
           (error "%s TOTP #%d @%d (%s), %S %d digits did not match: %S vs %S"
                  label i totp-override-time stamp algorithm digits want have))
diff --git a/totp.el b/totp.el
index b2a39095de..3bd3091f42 100644
--- a/totp.el
+++ b/totp.el
@@ -362,6 +362,8 @@ and EXPIRY is the seconds after the epoch when the TOTP 
expires."
           msg     (totp-hmac-message counter)
           hash    (hmac secret msg algo)
           totp    (% (totp-truncate-hash hash) (expt 10 digits)))
+    (let ((fmt (format "%%0%dd" digits)))
+      (setq totp (format fmt totp)))
     (list totp ttl expiry)))
 
 (defun totp-display-token (token &optional label)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]