using OtpNet; namespace Mirea.Api.Security.Services; public class TotpService { private readonly Totp _totp; public TotpService(string secret) { var secretBytes = Base32Encoding.ToBytes(secret); _totp = new Totp(secretBytes); } public string GenerateToken() => _totp.ComputeTotp(); public bool VerifyToken(string token) => _totp.VerifyTotp(token, out _, new VerificationWindow(2, 2)); }