Specify the OTP width while printing

This commit is contained in:
Lucas 2020-06-14 17:33:11 +00:00
parent 41ca24d151
commit 88ec5427c7
1 changed files with 2 additions and 2 deletions

4
cli.c
View File

@ -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;