TwoFactorAuth.Net icon indicating copy to clipboard operation
TwoFactorAuth.Net copied to clipboard

Not Working in Microsoft Authenticator App but in Google Authenticator

Open KBITSERVICES opened this issue 4 years ago • 2 comments

Hi,

i'm using the following code to generate QRCode for TOTP:

tfa = new TwoFactorAuth("ADRM", 6, 60);

secret = tfa.CreateSecret(80, CryptoSecureRequirement.RequireSecure);

secretlabel.Text = secret;


AppSettingsHandler.Handler.AddOrUpdateSetting("secret", secret);


              

String uri = tfa.GetQrText("ADRM", secret);


QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(uri, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);

                


pictureBox1.Image = qrCodeImage;

My Problem is that if i scan the Code with Microsoft Authenticator i get an other code as Google Authenticator.

Googles Code is correct, microsoft's isnt.

Can you help please?

KBITSERVICES avatar Feb 16 '21 18:02 KBITSERVICES

Not all authenticators support all variations of periods, digits, algorithms and number of secret bits. So I'd start with testing the most common combination: 30 second periods, 6 digits, sha1, 80 bits. I see you're using 60 second periods so I bet that's the problem.

RobThree avatar Feb 16 '21 21:02 RobThree

Just to add to this as I've come across a similar issue. I've had to push the algorithm being used down to SHA1 for the most broad compatibility, as to date, the Microsoft authenticator app still won't work with SHA256 or SHA512.

Using a 6 digit code and 30s period.

StuFrankish avatar Apr 19 '22 14:04 StuFrankish