38 lines
990 B
C#
38 lines
990 B
C#
using OtpNet;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace MFACodeGenerator
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var key = Base32Encoding.ToBytes(textBox1.Text.Replace(" ", string.Empty));
|
|
var secretCode =
|
|
new Totp(key, 30, OtpHashMode.Sha1, 6);
|
|
var authCode = secretCode.ComputeTotp();
|
|
MFACodeOutput.Text = authCode;
|
|
Clipboard.SetText(authCode, TextDataFormat.Text);
|
|
} catch
|
|
{
|
|
MFACodeOutput.Text = "Invalid TOTP Secret... Check your inputs!";
|
|
}
|
|
}
|
|
}
|
|
}
|