feat(StringExtension): Erstellen, um erforderliche String-Erweiterungsmethoden hinzuzufügen.

- IsValidTotp Erweiterung hinzugefügt, um die totp zu überprüfen.
This commit is contained in:
Developer 02
2024-12-11 18:22:45 +01:00
parent ba2518cdd2
commit 27db664b4d
3 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
using OtpNet;
namespace EnvelopeGenerator.Extensions
{
public static class StringExtension
{
public static bool IsValidTotp(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);
}
}
}