2fa helpers

This commit is contained in:
2022-12-13 16:25:36 +01:00
parent 8f3a20e5ba
commit c5cdb0f799
11 changed files with 297 additions and 26 deletions
+18
View File
@@ -212,4 +212,22 @@ public static class StringExtensions
return builder.ToString();
}
public static string FormatTwoFactorAuthenticationKey(this string unformattedKey)
{
var result = new StringBuilder();
int currentPosition = 0;
while (currentPosition + 4 < unformattedKey.Length)
{
result.Append(unformattedKey.AsSpan(currentPosition, 4)).Append(' ');
currentPosition += 4;
}
if (currentPosition < unformattedKey.Length)
{
result.Append(unformattedKey.AsSpan(currentPosition));
}
return result.ToString().ToLowerInvariant();
}
}