diff --git a/OTP.sln b/OTP.sln
new file mode 100644
index 0000000..57188df
--- /dev/null
+++ b/OTP.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33829.357
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OTP", "OTP\OTP.csproj", "{698CAA40-B8B1-4576-9F2F-305BD7522771}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {698CAA40-B8B1-4576-9F2F-305BD7522771}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {698CAA40-B8B1-4576-9F2F-305BD7522771}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {698CAA40-B8B1-4576-9F2F-305BD7522771}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {698CAA40-B8B1-4576-9F2F-305BD7522771}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5BF84EDB-F235-4846-9126-E6286960AE7F}
+ EndGlobalSection
+EndGlobal
diff --git a/OTP/App.config b/OTP/App.config
new file mode 100644
index 0000000..aee9adf
--- /dev/null
+++ b/OTP/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OTP/Form1.Designer.cs b/OTP/Form1.Designer.cs
new file mode 100644
index 0000000..6d71b27
--- /dev/null
+++ b/OTP/Form1.Designer.cs
@@ -0,0 +1,123 @@
+namespace OTP
+{
+ partial class Form1
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 窗体设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button1 = new System.Windows.Forms.Button();
+ this.button2 = new System.Windows.Forms.Button();
+ this.progressBar1 = new System.Windows.Forms.ProgressBar();
+ this.label2 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // listBox1
+ //
+ this.listBox1.FormattingEnabled = true;
+ this.listBox1.Location = new System.Drawing.Point(42, 38);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(473, 316);
+ this.listBox1.TabIndex = 0;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(582, 53);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(125, 25);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "TOTP Code";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(556, 302);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(85, 51);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "Generate";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(647, 302);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(85, 51);
+ this.button2.TabIndex = 3;
+ this.button2.Text = "button1";
+ this.button2.UseVisualStyleBackColor = true;
+ //
+ // progressBar1
+ //
+ this.progressBar1.Location = new System.Drawing.Point(556, 161);
+ this.progressBar1.Name = "progressBar1";
+ this.progressBar1.Size = new System.Drawing.Size(176, 44);
+ this.progressBar1.TabIndex = 4;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label2.Location = new System.Drawing.Point(584, 174);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(123, 20);
+ this.label2.TabIndex = 5;
+ this.label2.Text = "Remaining Time";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.progressBar1);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.listBox1);
+ this.Name = "Form1";
+ this.Text = "Main Window";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.ProgressBar progressBar1;
+ private System.Windows.Forms.Label label2;
+ }
+}
+
diff --git a/OTP/Form1.cs b/OTP/Form1.cs
new file mode 100644
index 0000000..0f9cfa0
--- /dev/null
+++ b/OTP/Form1.cs
@@ -0,0 +1,71 @@
+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;
+using OtpNet;
+
+namespace OTP
+{
+ public partial class Form1 : Form
+ {
+ private byte[] secretKey;
+ private Totp totp;
+ private Timer timer;
+
+ public Form1()
+ {
+ InitializeComponent();
+
+ secretKey = Base32Encoding.ToBytes("JBSWY3DPEHPK3PXP"); // 示例的 base32 编码
+ totp = new Totp(secretKey);
+
+ timer = new Timer();
+ timer.Interval = 1000; // 设置计时器间隔为 1 秒
+ timer.Tick += Timer_Tick;
+ }
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ int remainingSeconds = totp.RemainingSeconds();
+ int totalSeconds = 30;
+
+ progressBar1.Value = (totalSeconds - remainingSeconds) * progressBar1.Maximum / totalSeconds;
+ label2.Text = remainingSeconds.ToString();
+ if (remainingSeconds == 30)
+ {
+ GenerateAndDisplayTotp();
+ }
+ }
+
+ private void GenerateAndDisplayTotp()
+ {
+ // 生成新的 TOTP 密码
+ string newTotpCode = totp.ComputeTotp();
+
+ // 在标签上显示新生成的密码
+ // 使用Invoke确保在UI线程上更新UI元素
+ this.Invoke((MethodInvoker)(() => label1.Text = newTotpCode));
+ }
+
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ button1.Enabled = false; // 禁用按钮
+ GenerateAndDisplayTotp(); // 生成并显示 TOTP 密码
+
+ // 开始计时器
+ timer.Start();
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ button1.Enabled = true; // 在窗体加载时启用按钮
+ }
+
+ }
+}
diff --git a/OTP/Form1.resx b/OTP/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/OTP/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/OTP/OTP.csproj b/OTP/OTP.csproj
new file mode 100644
index 0000000..2569dbb
--- /dev/null
+++ b/OTP/OTP.csproj
@@ -0,0 +1,92 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {698CAA40-B8B1-4576-9F2F-305BD7522771}
+ WinExe
+ OTP
+ OTP
+ v4.8.1
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\Otp.NET.1.3.0\lib\net45\Otp.NET.dll
+
+
+
+
+ ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
+ True
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OTP/Program.cs b/OTP/Program.cs
new file mode 100644
index 0000000..5464fb9
--- /dev/null
+++ b/OTP/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace OTP
+{
+ internal static class Program
+ {
+ ///
+ /// 应用程序的主入口点。
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/OTP/Properties/AssemblyInfo.cs b/OTP/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..689d212
--- /dev/null
+++ b/OTP/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("OTP")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("OTP")]
+[assembly: AssemblyCopyright("Copyright © 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("698caa40-b8b1-4576-9f2f-305bd7522771")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OTP/Properties/Resources.Designer.cs b/OTP/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..541afbd
--- /dev/null
+++ b/OTP/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace OTP.Properties
+{
+
+
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OTP.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/OTP/Properties/Resources.resx b/OTP/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/OTP/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/OTP/Properties/Settings.Designer.cs b/OTP/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..53b4fe2
--- /dev/null
+++ b/OTP/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace OTP.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/OTP/Properties/Settings.settings b/OTP/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/OTP/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/OTP/packages.config b/OTP/packages.config
new file mode 100644
index 0000000..960b486
--- /dev/null
+++ b/OTP/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file