I'm writing a simple 2FA application, which generates TOTP codes in a flutter app, then I want the user to enter this code in an ASP.NET Core site, but I can't validate the code in the site.
In Flutter/Dart, I am using the library dart-otp and in ASP.NET Core, I am using kspearrin /Otp.NET
The code in Flutter/Dart is
var now = DateTime.now();
now = DateTime(2023, 04, 26, 10, 10, 10);
var code = OTP.generateTOTPCodeString(
'DDXFM42476476545', now.millisecondsSinceEpoch,
algorithm: Algorithm.SHA256, isGoogle: false);
print(code); // Outputs 667099
In C# the code is
string skey = "DDXFM42476476545";
var now = new DateTime(2023, 04, 26, 10, 10, 10);
var totp = new Totp(Base32Encoding.ToBytes(skey),30,OtpHashMode.Sha256);
//var totp = new Totp(Encoding.UTF8.GetBytes(skey), 30, OtpHashMode.Sha256);
var code = totp.ComputeTotp(now);//code : 734057
I don't know what is the problem of the code or if I am understanding something wrong?