14 lines
422 B
C#
14 lines
422 B
C#
using OtpNet;
|
|
|
|
namespace EnvelopeGenerator.Extensions
|
|
{
|
|
public static class StringExtension
|
|
{
|
|
public static bool IsValidTotp(this string totp, string secret)
|
|
{
|
|
var secret_bytes = Base32Encoding.ToBytes(secret);
|
|
var secret_totp = new Totp(secret_bytes);
|
|
return secret_totp.VerifyTotp(totp, out _, VerificationWindow.RfcSpecifiedNetworkDelay);
|
|
}
|
|
}
|
|
} |