TOTP sometimes returns 4 or 5 digit code

151 views
Skip to first unread message

Bono de Visser

unread,
Nov 23, 2015, 6:46:10 AM11/23/15
to django-otp
Hi,

Not really sure if this is the place to ask this kind of stuff, or that I should maybe create an issue (I doubt it is an issue). Sometimes when I generate a code using totp() and specify six digits; the function returns 4 or 5 digits. My assumption is that it has to do with the fact that it returns an integer, and that an integer can have leading zero's. I would just like to get some feedback to clear this up, and thought that it might be a good idea to place it in the dicussion groups.

Cheers,
Bono

Peter Sagerson

unread,
Nov 23, 2015, 12:19:42 PM11/23/15
to djang...@googlegroups.com
Hello,

That’s what it is. If you need it as a six-digit string, you can use format(token, '06d’). django-otp-twilio does this, for example.

Thanks,
Peter
> --
> You received this message because you are subscribed to the Google Groups "django-otp" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-otp+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Bono de Visser

unread,
Nov 24, 2015, 8:29:56 AM11/24/15
to django-otp
Okay great thanks. Kind of late, but I meant "can' t" not "can" back there ;)
Reply all
Reply to author
Forward
0 new messages