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

@ -18,7 +18,6 @@
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.0" />
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="QRCoder-ImageSharp" Version="0.10.0" />
<PackageReference Include="UserManager.Application" Version="2.0.0" />

View File

@ -10,6 +10,7 @@
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="7.0.19" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Otp.NET" Version="1.4.0" />
</ItemGroup>
<ItemGroup>

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);
}
}
}