Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Exception when code type is integer (expected string) #38
Code to reproduce
$tfa = new RobThree\Auth\TwoFactorAuth("TEST"); $tfa->verifyCode("USJNHRTSCEAY2OME6IB7CLEE6HACYQGN", 123123);
$tfa = new RobThree\Auth\TwoFactorAuth("TEST"); $tfa->verifyCode("USJNHRTSCEAY2OME6IB7CLEE6HACYQGN", (string) 123123);
In case of the
Uh, no. The code is, and should be, a string. Just because it only contains digits doesn't make it an integer. You already discovered that leading zeroes will become a problem. Just like a phone number (which also, usually, only contains numbers) is a string, this verification code is supposed to be a string as well.
Also your argument about less cpu ticks is questionable at best. If we're measuring CPU cycles than the hash functions will use orders of magnitude more; switching to integers as an 'optimisation' is a micro-optimisation at best.
If anything, I should probably add typehinting someday and ensure all arguments are of the correct type.