$secretKey = $this->twofa->generateSecretKey(); // user define key
Then create the QR code
$twofaQrCode = $this->twofa->getQRCodeUrl($config['qr_company'], $user->email, $secretKey);
// render qr code url as a scanable image
$writer = new Writer(
new ImageRenderer(
new RendererStyle(400),
new ImagickImageBackEnd()
)
);
// Write code to a string and store image
$url = $writer->writeString($twofaQrCode);
Storage::disk('public')->put('qrcode-' . $user->getKey() . '.png', $url);
This had previously worked fine, but now suddenly, the code Im given from the QR code does not match the actual code (There is a brief time that it does but not correct every other time).
I have came into the Google2FA class, and the findValidOTP function, if I dump out the hash_equals($this->oathTotp($secret, $startingTimestamp), $key) it returns false most of the time, if I dump out the code without the hash_equals function, it shows a completely different code to what the QR code in my authenticator app shows.
So I create the code as follows:
$secretKey = $this->twofa->generateSecretKey(); // user define key
Then create the QR code
This had previously worked fine, but now suddenly, the code Im given from the QR code does not match the actual code (There is a brief time that it does but not correct every other time).
I have came into the Google2FA class, and the findValidOTP function, if I dump out the
hash_equals($this->oathTotp($secret, $startingTimestamp), $key)
it returns false most of the time, if I dump out the code without the hash_equals function, it shows a completely different code to what the QR code in my authenticator app shows.