From 88ec5427c7fdaa3fd2e968990f3c82f03369e155 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 14 Jun 2020 17:33:11 +0000 Subject: [PATCH] Specify the OTP width while printing --- cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli.c b/cli.c index b44a482..2f68bb7 100644 --- a/cli.c +++ b/cli.c @@ -72,13 +72,13 @@ main(int argc, char *argv[]) r = hotp(OTP_HMAC_SHA1, argv[0], strlen(argv[0]), counter, 6); if (r == -1) errx(1, "couldn't calculate HOTP"); - printf("%" PRId32 "\n", r); + printf("%0*" PRId32 "\n", 6, r); } else { r = totp(OTP_HMAC_SHA1, argv[0], strlen(argv[0]), counter, 30, 8); if (r == -1) errx(1, "couldn't calculate TOTP"); - printf("%" PRId32 "\n", r); + printf("%0*" PRId32 "\n", 8, r); } return 0;