From 27db664b4da01bc9fd3dcb72cc1f5ca34e7d4136 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 11 Dec 2024 18:22:45 +0100 Subject: [PATCH] =?UTF-8?q?feat(StringExtension):=20Erstellen,=20um=20erfo?= =?UTF-8?q?rderliche=20String-Erweiterungsmethoden=20hinzuzuf=C3=BCgen.=20?= =?UTF-8?q?=20-=20IsValidTotp=20Erweiterung=20hinzugef=C3=BCgt,=20um=20die?= =?UTF-8?q?=20totp=20zu=20=C3=BCberpr=C3=BCfen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EnvelopeGenerator.Application.csproj | 1 - .../EnvelopeGenerator.Extensions.csproj | 1 + EnvelopeGenerator.Extensions/StringExtension.cs | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 EnvelopeGenerator.Extensions/StringExtension.cs diff --git a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj index 0e120bcb..6032bb17 100644 --- a/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj +++ b/EnvelopeGenerator.Application/EnvelopeGenerator.Application.csproj @@ -18,7 +18,6 @@ - diff --git a/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj b/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj index 8467bc11..f4ea6b21 100644 --- a/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj +++ b/EnvelopeGenerator.Extensions/EnvelopeGenerator.Extensions.csproj @@ -10,6 +10,7 @@ + diff --git a/EnvelopeGenerator.Extensions/StringExtension.cs b/EnvelopeGenerator.Extensions/StringExtension.cs new file mode 100644 index 00000000..0e6e7669 --- /dev/null +++ b/EnvelopeGenerator.Extensions/StringExtension.cs @@ -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); + } + } +} \ No newline at end of file