Generated codes do not match Google Authenticator results
See original GitHub issueI am using this code:
string secret = "KREQPD7NXSGO3T3B";
while (true)
{
byte[] secretBytes = new Base32Encoder().Decode(secret);
OtpNet.Totp totp = new OtpNet.Totp(secretBytes);
string twoFactorCode = totp.ComputeTotp();
Console.WriteLine("Two factor code: " + twoFactorCode);
System.Threading.Thread.Sleep(2000);
}
Now if you take that same string (for secret
) and put it in to Google Authenticator manually, you will notice that this code generates different keys. On the otherhand, if I use a different value for secret (eg “uhj34qsyuwftzji4qq6k3c3wnstdb57m”) then both the values generated by OtpNet and Google Authenticator will match.
What am I doing wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Generated codes do not match with PyOTP sample
Go to the main menu on the Google Authenticator app Tap More and then Settings. Tap Time correction for codes Tap Sync now...
Read more >Fix common issues with 2-Step Verification
My Google Authenticator codes don't work · On your Android device, go to the main menu of the Google Authenticator app. · Tap...
Read more >[RESOLVED] PHP code not matching Google Authenticator ...
Hello, I'm trying to get some PHP code matching what the Google Authenticator on my phone outputs. I'm using HOTP (Once I get...
Read more >How to Fix Google Authenticator Codes That Have ...
1. Sync the App's Time. Mobile users might find that their Google Authenticator codes aren't working when logging into their accounts. And ...
Read more >Authenticator App codes do not work—does not allow any ...
I have tried using Authenticator App codes generated by Authy (iOS app), which do no work. I have tried accessing codes from other...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just got it. The way to get bytes[] is wrong. I need to use
var secretKey = Base32Encoding.ToBytes(OtpSecretKey);
Then OtpNet and Google Authenticator will match.@derekantrican Great