google2fa-laravel
google2fa-laravel copied to clipboard
hash_equals(): Expected user_string to be a string, int given
Hi,
I am facing the issue, "hash_equals(): Expected user_string to be a string, int given" while verifying the authentication code API.
Also facing this error right now after upgrading laravel to latest version. Did you manage to resolve this issue? @sakthivel-globalizeme
First, there's no hash_equals call in google2fa-laravel, it's part of https://github.com/antonioribeiro/google2fa actually.
user_string to be a string, int given
user_string is the 2nd argument to hash_equals, which means it's they $key
(which in practice means it's the OTP).
OTPs usually look like "123456" and thus might be interpreted as integers somewhere.
You need to figure out where this happens.
@mfn @joppx25 @sakthivel-globalizeme You can use the strval() function to convert a number to a string. So to verify you can do Google2FA::verifyKey($employee->google2fa_secret, strval($request->otp));
// true or false