Iceshrimp.NET/Iceshrimp.Backend/Core/Helpers/TotpHelper.cs
2024-11-21 20:04:21 +01:00

12 lines
No EOL
325 B
C#

using OtpNet;
namespace Iceshrimp.Backend.Core.Helpers;
public static class TotpHelper
{
public static bool Validate(string secret, string totp)
=> new Totp(Base32Encoding.ToBytes(secret)).VerifyTotp(totp, out _);
public static string GenerateSecret()
=> Base32Encoding.ToString(KeyGeneration.GenerateRandomKey());
}