Compare commits

...

16 Commits
main ... net8.0

Author SHA1 Message Date
774b328a41 更新 README.md 2024-08-22 20:22:23 +08:00
d2b21eb414 上传文件至 img 2024-08-22 20:21:18 +08:00
8a6676062d up 2024-08-22 20:08:10 +08:00
ec4fd3eaa6 update 2024-08-22 19:07:59 +08:00
56a7c37bec 依赖更新
升级了两个包的版本

更新了`OTP.csproj`中的`EntityFramework`和`System.Drawing.Common`包版本。`EntityFramework`包从`6.4.4`升级到`6.5.1`,`System.Drawing.Common`包从`8.0.6`升级到`8.0.7`。
2024-07-22 00:29:31 +08:00
931a80c9e8 update 2024-06-08 16:25:07 +08:00
4d508f6fe3 更新依赖包 2024-03-08 13:45:33 +08:00
816ce719b9 更新 README.md 2024-03-08 05:37:13 +00:00
5d0334cf8f update to .net 8.0 2024-03-08 13:35:50 +08:00
7186770928 NuGet包更新 2024-03-08 13:16:35 +08:00
5081872eae update README.md 2023-09-02 15:10:21 +08:00
fa93990602 fix3 2023-09-02 15:07:55 +08:00
d09149391d fix2 2023-09-02 14:32:42 +08:00
434814a085 fix 1 2023-09-02 13:08:33 +08:00
bf873ce0c8 update readme.md 2023-09-01 22:58:58 +08:00
71f5d63fec net7.0 init upload (incomplete) 2023-09-01 22:57:51 +08:00
20 changed files with 605 additions and 1403 deletions

View File

@ -1,9 +1,9 @@

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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OTP", "OTP\OTP.csproj", "{698CAA40-B8B1-4576-9F2F-305BD7522771}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

270
OTP/Form1.Designer.cs generated
View File

@ -29,162 +29,166 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
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.label2 = new System.Windows.Forms.Label();
this.circularProgressBar1 = new CircularProgressBar.CircularProgressBar();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
listBox1 = new System.Windows.Forms.ListBox();
label1 = new System.Windows.Forms.Label();
button1 = new System.Windows.Forms.Button();
button2 = new System.Windows.Forms.Button();
label2 = new System.Windows.Forms.Label();
button3 = new System.Windows.Forms.Button();
button4 = new System.Windows.Forms.Button();
progressBar1 = new System.Windows.Forms.ProgressBar();
label3 = new System.Windows.Forms.Label();
label4 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
SuspendLayout();
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 20;
this.listBox1.Location = new System.Drawing.Point(42, 38);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(473, 364);
this.listBox1.TabIndex = 0;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
listBox1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
listBox1.FormattingEnabled = true;
listBox1.ItemHeight = 27;
listBox1.Location = new System.Drawing.Point(49, 44);
listBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
listBox1.Name = "listBox1";
listBox1.Size = new System.Drawing.Size(551, 409);
listBox1.TabIndex = 0;
listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(549, 59);
this.label1.MinimumSize = new System.Drawing.Size(197, 37);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(197, 37);
this.label1.TabIndex = 1;
this.label1.Text = "TOTP Code";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold);
label1.Location = new System.Drawing.Point(640, 56);
label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(230, 43);
label1.TabIndex = 1;
label1.Text = "TOTP Code";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
label1.Click += Label1_Click;
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(549, 294);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(92, 23);
this.button1.TabIndex = 3;
this.button1.Text = "Generate";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
button1.Enabled = false;
button1.Location = new System.Drawing.Point(640, 354);
button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button1.Name = "button1";
button1.Size = new System.Drawing.Size(107, 27);
button1.TabIndex = 3;
button1.Text = "Generate";
button1.UseVisualStyleBackColor = true;
button1.Click += Button1_Click;
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(647, 294);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(99, 111);
this.button2.TabIndex = 3;
this.button2.Text = "Copy";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
button2.Enabled = false;
button2.Location = new System.Drawing.Point(755, 354);
button2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button2.Name = "button2";
button2.Size = new System.Drawing.Size(115, 94);
button2.TabIndex = 3;
button2.Text = "Copy";
button2.UseVisualStyleBackColor = true;
button2.Click += Button2_Click;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
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, 247);
this.label2.MinimumSize = new System.Drawing.Size(123, 20);
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;
//
// circularProgressBar1
//
this.circularProgressBar1.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
this.circularProgressBar1.AnimationSpeed = 500;
this.circularProgressBar1.BackColor = System.Drawing.Color.Transparent;
this.circularProgressBar1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.circularProgressBar1.ForeColor = System.Drawing.Color.White;
this.circularProgressBar1.InnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(73)))), ((int)(((byte)(94)))));
this.circularProgressBar1.InnerMargin = 2;
this.circularProgressBar1.InnerWidth = -1;
this.circularProgressBar1.Location = new System.Drawing.Point(587, 124);
this.circularProgressBar1.MarqueeAnimationSpeed = 2000;
this.circularProgressBar1.Maximum = 30;
this.circularProgressBar1.Name = "circularProgressBar1";
this.circularProgressBar1.OuterColor = System.Drawing.Color.White;
this.circularProgressBar1.OuterMargin = -25;
this.circularProgressBar1.OuterWidth = 26;
this.circularProgressBar1.ProgressColor = System.Drawing.Color.FromArgb(((int)(((byte)(52)))), ((int)(((byte)(150)))), ((int)(((byte)(218)))));
this.circularProgressBar1.ProgressWidth = 20;
this.circularProgressBar1.SecondaryFont = new System.Drawing.Font("Microsoft Sans Serif", 36F);
this.circularProgressBar1.Size = new System.Drawing.Size(120, 120);
this.circularProgressBar1.StartAngle = 270;
this.circularProgressBar1.SubscriptColor = System.Drawing.Color.Transparent;
this.circularProgressBar1.SubscriptMargin = new System.Windows.Forms.Padding(10, -35, 0, 0);
this.circularProgressBar1.SubscriptText = ".23";
this.circularProgressBar1.SuperscriptColor = System.Drawing.Color.Transparent;
this.circularProgressBar1.SuperscriptMargin = new System.Windows.Forms.Padding(10, 35, 0, 0);
this.circularProgressBar1.SuperscriptText = "°C";
this.circularProgressBar1.TabIndex = 6;
this.circularProgressBar1.Text = "time";
this.circularProgressBar1.TextMargin = new System.Windows.Forms.Padding(21, 2, 0, 0);
this.circularProgressBar1.Value = 30;
label2.BackColor = System.Drawing.Color.Transparent;
label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
label2.Location = new System.Drawing.Point(640, 297);
label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(230, 23);
label2.TabIndex = 5;
label2.Text = "Remaining Time";
label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button3
//
this.button3.Location = new System.Drawing.Point(549, 323);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(92, 23);
this.button3.TabIndex = 7;
this.button3.Text = "Manage";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
button3.Location = new System.Drawing.Point(640, 388);
button3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button3.Name = "button3";
button3.Size = new System.Drawing.Size(107, 27);
button3.TabIndex = 7;
button3.Text = "Manage";
button3.UseVisualStyleBackColor = true;
button3.Click += Button3_Click;
//
// button4
//
this.button4.Location = new System.Drawing.Point(549, 352);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(92, 23);
this.button4.TabIndex = 8;
this.button4.Text = "Refresh";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
button4.Location = new System.Drawing.Point(640, 421);
button4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button4.Name = "button4";
button4.Size = new System.Drawing.Size(107, 27);
button4.TabIndex = 8;
button4.Text = "Refresh";
button4.UseVisualStyleBackColor = true;
button4.Click += Button4_Click;
//
// button5
// progressBar1
//
this.button5.Location = new System.Drawing.Point(549, 382);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(92, 23);
this.button5.TabIndex = 9;
this.button5.Text = "Troubleshooting";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
progressBar1.Location = new System.Drawing.Point(640, 177);
progressBar1.Maximum = 30;
progressBar1.Name = "progressBar1";
progressBar1.Size = new System.Drawing.Size(230, 51);
progressBar1.TabIndex = 10;
//
// label3
//
label3.Font = new System.Drawing.Font("Segoe UI", 24F);
label3.Location = new System.Drawing.Point(640, 231);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(230, 45);
label3.TabIndex = 11;
label3.Text = "1";
label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
label4.AutoSize = true;
label4.Font = new System.Drawing.Font("Segoe UI", 12F);
label4.Location = new System.Drawing.Point(640, 129);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(45, 21);
label4.TabIndex = 12;
label4.Text = "Next:";
//
// label5
//
label5.AutoSize = true;
label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
label5.Location = new System.Drawing.Point(713, 130);
label5.Name = "label5";
label5.Size = new System.Drawing.Size(92, 20);
label5.TabIndex = 13;
label5.Text = "Next Code";
label5.Click += Label5_Click;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(775, 440);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.label2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.circularProgressBar1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Text = "TOTP";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.VisibleChanged += new System.EventHandler(this.Form1_VisibleChanged);
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(904, 508);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(progressBar1);
Controls.Add(button4);
Controls.Add(button3);
Controls.Add(label2);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(label1);
Controls.Add(listBox1);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Name = "Form1";
Text = "TOTP";
FormClosing += Form1_FormClosing;
Load += Form1_Load;
VisibleChanged += Form1_VisibleChanged;
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -194,10 +198,12 @@
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label2;
private CircularProgressBar.CircularProgressBar circularProgressBar1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
}
}

View File

@ -1,17 +1,9 @@
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;
using System.IO;
using OtpNet;
using System;
using System.Data.SQLite;
using System.IO;
using System.Reflection;
using ZXing.QrCode.Internal;
using System.Windows.Forms;
namespace OTP
{
@ -20,9 +12,9 @@ namespace OTP
private byte[] secretKey;
private Totp totp;
private Timer timer;
private string connectionString = "Data Source=key.db;Version=3;";
private string embeddedDatabaseResource = "OTP.empty_key.db";
private int runonce=0;
private const string connectionString = "Data Source=key.db;Version=3;";
private const string embeddedDatabaseResource = "OTP.empty_key.db";
private int runonce = 0;
public Form1()
{
@ -31,8 +23,10 @@ namespace OTP
//secretKey = Base32Encoding.ToBytes("JBSWY3DPEHPK3PXP"); // 示例的 base32 编码
//totp = new Totp(secretKey);
timer = new Timer();
timer.Interval = 1000; // 设置计时器间隔为 1 秒
timer = new Timer
{
Interval = 1000 // 设置计时器间隔为 1 秒
};
timer.Tick += Timer_Tick;
}
public class TitleInfo
@ -50,8 +44,8 @@ namespace OTP
private void Timer_Tick(object sender, EventArgs e)
{
int remainingSeconds = totp.RemainingSeconds();
circularProgressBar1.Text = remainingSeconds.ToString();
circularProgressBar1.Value = remainingSeconds;
label3.Text = remainingSeconds.ToString();
progressBar1.Value = remainingSeconds;
if (remainingSeconds == 30)
{
GenerateAndDisplayTotp();
@ -62,14 +56,16 @@ namespace OTP
{
// 生成新的 TOTP 密码
string newTotpCode = totp.ComputeTotp();
string newNextTotpCode = totp.ComputeTotp(DateTime.UtcNow.AddSeconds(30));
// 在标签上显示新生成的密码
// 使用Invoke确保在UI线程上更新UI元素
this.Invoke((MethodInvoker)(() => label1.Text = newTotpCode));
this.Invoke((System.Windows.Forms.MethodInvoker)(() => label1.Text = newTotpCode));
this.Invoke((System.Windows.Forms.MethodInvoker)(() => label5.Text = newNextTotpCode));
}
private void button1_Click(object sender, EventArgs e)
private void Button1_Click(object sender, EventArgs e)
{
button1.Enabled = false; // 禁用生成按钮
button2.Enabled = true; // 启用复制按钮
@ -89,20 +85,16 @@ namespace OTP
ExtractEmbeddedDatabase();
}
}
private void ExtractEmbeddedDatabase()
private static void ExtractEmbeddedDatabase()
{
// 从嵌入的资源中复制数据库文件到同目录下
try
{
using (Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedDatabaseResource))
{
using (FileStream fileStream = new FileStream("key.db", FileMode.Create))
{
resourceStream.CopyTo(fileStream);
}
}
using Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedDatabaseResource);
using FileStream fileStream = new("key.db", FileMode.Create);
resourceStream.CopyTo(fileStream);
}
catch (Exception ex)
{
@ -114,32 +106,26 @@ namespace OTP
{
try
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
using SQLiteConnection connection = new(connectionString);
connection.Open();
using SQLiteCommand command = new("SELECT Id, Title, SecretKey FROM TotpData", connection);
using SQLiteDataReader reader = command.ExecuteReader();
listBox1.Items.Clear(); // 清空现有数据
while (reader.Read())
{
connection.Open();
int id = reader.GetInt32(0);
string title = reader.GetString(1);
string secretKey = reader.GetString(2);
using (SQLiteCommand command = new SQLiteCommand("SELECT Id, Title, SecretKey FROM TotpData", connection))
TitleInfo titleInfo = new()
{
using (SQLiteDataReader reader = command.ExecuteReader())
{
listBox1.Items.Clear(); // 清空现有数据
while (reader.Read())
{
int id = reader.GetInt32(0);
string title = reader.GetString(1);
string secretKey = reader.GetString(2);
Id = id,
Title = title,
SecretKey = secretKey
};
TitleInfo titleInfo = new TitleInfo
{
Id = id,
Title = title,
SecretKey = secretKey
};
listBox1.Items.Add(titleInfo);
}
}
}
listBox1.Items.Add(titleInfo);
}
}
catch (Exception ex)
@ -148,12 +134,11 @@ namespace OTP
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedIndex >= 0) // Ensure an item is selected
{
TitleInfo selectedTitleInfo = listBox1.SelectedItem as TitleInfo;
if (selectedTitleInfo != null)
if (listBox1.SelectedItem is TitleInfo selectedTitleInfo)
{
if (runonce == 0)
{
@ -178,15 +163,15 @@ namespace OTP
}
private void button2_Click(object sender, EventArgs e)
private void Button2_Click(object sender, EventArgs e)
{
Clipboard.SetText(label1.Text);
}
private void button3_Click(object sender, EventArgs e)
private void Button3_Click(object sender, EventArgs e)
{
// 创建 Form2 实例
Form2 form2 = new Form2();
Form2 form2 = new();
// 显示新创建的 Form2 实例
form2.Show();
@ -214,10 +199,11 @@ namespace OTP
LoadTitlesToListBox();
runonce = 0;
label1.Text = "TOTP Code";
label1.Text = "Next Code";
button1.Enabled = false;
button2.Enabled = false;
circularProgressBar1.Text = "time";
circularProgressBar1.Value = 30;
label3.Text = "time";
progressBar1.Value = 30;
}
else
{
@ -225,15 +211,19 @@ namespace OTP
}
}
private void button4_Click(object sender, EventArgs e)
private void Button4_Click(object sender, EventArgs e)
{
LoadTitlesToListBox();
}
private void button5_Click(object sender, EventArgs e)
private void Label1_Click(object sender, EventArgs e)
{
Form4 form4 = new Form4();
form4.Show();
Clipboard.SetText(label1.Text);
}
private void Label5_Click(object sender, EventArgs e)
{
Clipboard.SetText(label5.Text);
}
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

154
OTP/Form2.Designer.cs generated
View File

@ -28,101 +28,107 @@
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
panel1 = new System.Windows.Forms.Panel();
dataGridView1 = new System.Windows.Forms.DataGridView();
button1 = new System.Windows.Forms.Button();
button2 = new System.Windows.Forms.Button();
button3 = new System.Windows.Forms.Button();
button4 = new System.Windows.Forms.Button();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.dataGridView1);
this.panel1.Location = new System.Drawing.Point(12, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(595, 287);
this.panel1.TabIndex = 0;
panel1.Controls.Add(dataGridView1);
panel1.Location = new System.Drawing.Point(14, 14);
panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
panel1.Name = "panel1";
panel1.Size = new System.Drawing.Size(694, 331);
panel1.TabIndex = 0;
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Size = new System.Drawing.Size(595, 287);
this.dataGridView1.TabIndex = 0;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
dataGridView1.Location = new System.Drawing.Point(0, 0);
dataGridView1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new System.Drawing.Size(694, 331);
dataGridView1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(60, 314);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(107, 41);
this.button1.TabIndex = 1;
this.button1.Text = "New Record";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
button1.Location = new System.Drawing.Point(70, 362);
button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button1.Name = "button1";
button1.Size = new System.Drawing.Size(125, 47);
button1.TabIndex = 1;
button1.Text = "New Record";
button1.UseVisualStyleBackColor = true;
button1.Click += Button1_Click;
//
// button2
//
this.button2.Location = new System.Drawing.Point(187, 314);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(107, 41);
this.button2.TabIndex = 2;
this.button2.Text = "Delete Record(s)";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
button2.Location = new System.Drawing.Point(218, 362);
button2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button2.Name = "button2";
button2.Size = new System.Drawing.Size(125, 47);
button2.TabIndex = 2;
button2.Text = "Delete Record(s)";
button2.UseVisualStyleBackColor = true;
button2.Click += Button2_Click;
//
// button3
//
this.button3.Location = new System.Drawing.Point(314, 314);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(107, 41);
this.button3.TabIndex = 3;
this.button3.Text = "Save Changes";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
button3.Location = new System.Drawing.Point(366, 362);
button3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button3.Name = "button3";
button3.Size = new System.Drawing.Size(125, 47);
button3.TabIndex = 3;
button3.Text = "Save Changes";
button3.UseVisualStyleBackColor = true;
button3.Click += Button3_Click;
//
// button4
//
this.button4.Location = new System.Drawing.Point(439, 314);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(107, 41);
this.button4.TabIndex = 4;
this.button4.Text = "Discard Changes";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
button4.Location = new System.Drawing.Point(512, 362);
button4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button4.Name = "button4";
button4.Size = new System.Drawing.Size(125, 47);
button4.TabIndex = 4;
button4.Text = "Discard Changes";
button4.UseVisualStyleBackColor = true;
button4.Click += Button4_Click;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(619, 367);
this.ControlBox = false;
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form2";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Data Manage";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form2_FormClosing);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(722, 437);
ControlBox = false;
Controls.Add(button4);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(panel1);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
Name = "Form2";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Data Manage";
FormClosing += Form2_FormClosing;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion

View File

@ -1,22 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
using System.Windows.Forms;
namespace OTP
{
public partial class Form2 : Form
{
private string connectionString = "Data Source=key.db;Version=3;";
private string backupPath = "key.db.bak"; // 备份数据库文件的路径
private const string connectionString = "Data Source=key.db;Version=3;";
private const string backupPath = "key.db.bak"; // 备份数据库文件的路径
private string sourceFileHash = ""; // 原始数据库文件的哈希值
public Form2()
@ -72,16 +65,12 @@ namespace OTP
}
}
// 计算文件的SHA-256哈希值
private string CalculateSHA256Hash(string filePath)
private static string CalculateSHA256Hash(string filePath)
{
using (SHA256 sha256 = SHA256.Create())
{
using (FileStream stream = File.OpenRead(filePath))
{
byte[] hashBytes = sha256.ComputeHash(stream);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
}
}
using SHA256 sha256 = SHA256.Create();
using FileStream stream = File.OpenRead(filePath);
byte[] hashBytes = sha256.ComputeHash(stream);
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
}
@ -93,51 +82,42 @@ namespace OTP
{
dataGridView1.Rows.Clear(); // 清空现有数据
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using SQLiteConnection connection = new(connectionString);
connection.Open();
using (SQLiteCommand command = new SQLiteCommand("SELECT Id, Title FROM TotpData", connection))
{
using (SQLiteDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
int id = reader.GetInt32(0);
string title = reader.GetString(1);
dataGridView1.Rows.Add(title);
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Tag = id; // 将 Id 存储在行的 Tag 属性中
}
}
}
using SQLiteCommand command = new("SELECT Id, Title FROM TotpData", connection);
using SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32(0);
string title = reader.GetString(1);
dataGridView1.Rows.Add(title);
dataGridView1.Rows[^1].Tag = id; // 将 Id 存储在行的 Tag 属性中
}
}
private void button1_Click(object sender, EventArgs e)
private void Button1_Click(object sender, EventArgs e)
{
using (Form3 form3 = new Form3())
{
DialogResult result = form3.ShowDialog();
using Form3 form3 = new();
DialogResult result = form3.ShowDialog();
if (result == DialogResult.OK)
{
// 在 Form3 中添加数据完成后,刷新数据
LoadData();
}
if (result == DialogResult.OK)
{
// 在 Form3 中添加数据完成后,刷新数据
LoadData();
}
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
Form1 form1 = Application.OpenForms["Form1"] as Form1;
if (form1 != null)
if (Application.OpenForms["Form1"] is Form1 form1)
{
form1.Show();
}
}
private void button2_Click(object sender, EventArgs e)
private void Button2_Click(object sender, EventArgs e)
{
try
{
@ -160,20 +140,16 @@ namespace OTP
}
}
private void DeleteRecordFromDatabase(int recordId)
private static void DeleteRecordFromDatabase(int recordId)
{
try
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using SQLiteConnection connection = new(connectionString);
connection.Open();
using (SQLiteCommand command = new SQLiteCommand("DELETE FROM TotpData WHERE ID = @ID", connection))
{
command.Parameters.AddWithValue("@ID", recordId);
command.ExecuteNonQuery();
}
}
using SQLiteCommand command = new("DELETE FROM TotpData WHERE ID = @ID", connection);
command.Parameters.AddWithValue("@ID", recordId);
command.ExecuteNonQuery();
}
catch (Exception ex)
{
@ -181,7 +157,7 @@ namespace OTP
}
}
private void button3_Click(object sender, EventArgs e)
private void Button3_Click(object sender, EventArgs e)
{
// 删除备份文件
if (File.Exists(backupPath))
@ -193,7 +169,7 @@ namespace OTP
this.Close();
}
private void button4_Click(object sender, EventArgs e)
private void Button4_Click(object sender, EventArgs e)
{
try
{

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

313
OTP/Form3.Designer.cs generated
View File

@ -28,226 +28,172 @@
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button7 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label6 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
label1 = new System.Windows.Forms.Label();
textBox1 = new System.Windows.Forms.TextBox();
label2 = new System.Windows.Forms.Label();
textBox2 = new System.Windows.Forms.TextBox();
button1 = new System.Windows.Forms.Button();
button2 = new System.Windows.Forms.Button();
button4 = new System.Windows.Forms.Button();
button6 = new System.Windows.Forms.Button();
label3 = new System.Windows.Forms.Label();
label4 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
groupBox1 = new System.Windows.Forms.GroupBox();
groupBox1.SuspendLayout();
SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(27, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Title";
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(30, 15);
label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(29, 15);
label1.TabIndex = 0;
label1.Text = "Title";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 10);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(202, 20);
this.textBox1.TabIndex = 1;
textBox1.Location = new System.Drawing.Point(84, 12);
textBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
textBox1.Name = "textBox1";
textBox1.Size = new System.Drawing.Size(235, 23);
textBox1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(54, 13);
this.label2.TabIndex = 2;
this.label2.Text = "secretKey";
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(14, 47);
label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(57, 15);
label2.TabIndex = 2;
label2.Text = "secretKey";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(72, 38);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(202, 20);
this.textBox2.TabIndex = 3;
textBox2.Location = new System.Drawing.Point(84, 44);
textBox2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
textBox2.Name = "textBox2";
textBox2.Size = new System.Drawing.Size(235, 23);
textBox2.TabIndex = 3;
//
// button1
//
this.button1.Location = new System.Drawing.Point(72, 68);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 45);
this.button1.TabIndex = 4;
this.button1.Text = "Add";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
button1.Location = new System.Drawing.Point(84, 78);
button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button1.Name = "button1";
button1.Size = new System.Drawing.Size(117, 52);
button1.TabIndex = 4;
button1.Text = "Add";
button1.UseVisualStyleBackColor = true;
button1.Click += Button1_Click;
//
// button2
//
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.Location = new System.Drawing.Point(174, 68);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(100, 45);
this.button2.TabIndex = 5;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Location = new System.Drawing.Point(292, 4);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(176, 23);
this.button3.TabIndex = 6;
this.button3.Text = "Scan QR Code from Screenshot";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
button2.Location = new System.Drawing.Point(203, 78);
button2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button2.Name = "button2";
button2.Size = new System.Drawing.Size(117, 52);
button2.TabIndex = 5;
button2.Text = "Cancel";
button2.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.Location = new System.Drawing.Point(292, 33);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(176, 23);
this.button4.TabIndex = 7;
this.button4.Text = "Scan QR Code from Image File";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(292, 62);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(176, 23);
this.button5.TabIndex = 8;
this.button5.Text = "Scan QR Code with Camera";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
button4.Location = new System.Drawing.Point(341, 9);
button4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button4.Name = "button4";
button4.Size = new System.Drawing.Size(205, 27);
button4.TabIndex = 7;
button4.Text = "Scan QR Code from Image File";
button4.UseVisualStyleBackColor = true;
button4.Click += Button4_Click;
//
// button6
//
this.button6.Location = new System.Drawing.Point(292, 91);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(176, 23);
this.button6.TabIndex = 9;
this.button6.Text = "Import from Clipboard";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
button6.Location = new System.Drawing.Point(341, 44);
button6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
button6.Name = "button6";
button6.Size = new System.Drawing.Size(205, 27);
button6.TabIndex = 9;
button6.Text = "Import from Clipboard";
button6.UseVisualStyleBackColor = true;
button6.Click += Button6_Click;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(24, 33);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(33, 13);
this.label3.TabIndex = 11;
this.label3.Text = "None";
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(28, 38);
label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(36, 15);
label3.TabIndex = 11;
label3.Text = "None";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(24, 59);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(37, 13);
this.label4.TabIndex = 12;
this.label4.Text = "Status";
label4.AutoSize = true;
label4.Location = new System.Drawing.Point(28, 68);
label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(39, 15);
label4.TabIndex = 12;
label4.Text = "Status";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(24, 86);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(25, 13);
this.label5.TabIndex = 13;
this.label5.Text = "Info";
label5.AutoSize = true;
label5.Location = new System.Drawing.Point(28, 99);
label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label5.Name = "label5";
label5.Size = new System.Drawing.Size(28, 15);
label5.TabIndex = 13;
label5.Text = "Info";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.button7);
this.groupBox1.Controls.Add(this.pictureBox1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Location = new System.Drawing.Point(15, 148);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(453, 288);
this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Debug Info";
//
// button7
//
this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button7.Location = new System.Drawing.Point(366, 162);
this.button7.MinimumSize = new System.Drawing.Size(75, 75);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(75, 75);
this.button7.TabIndex = 15;
this.button7.Text = "Pause";
this.button7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(105, 113);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(255, 169);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 14;
this.pictureBox1.TabStop = false;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(8, 146);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(91, 91);
this.label6.TabIndex = 16;
this.label6.Text = "Note:\r\n使用相机扫码会\r\n自动填充内容到\r\n输入框\r\n因为坑比较多不\r\n好填所以这个\r\n功能不是很完善";
groupBox1.Controls.Add(label4);
groupBox1.Controls.Add(label5);
groupBox1.Controls.Add(label3);
groupBox1.Location = new System.Drawing.Point(18, 171);
groupBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
groupBox1.Name = "groupBox1";
groupBox1.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
groupBox1.Size = new System.Drawing.Size(528, 214);
groupBox1.TabIndex = 14;
groupBox1.TabStop = false;
groupBox1.Text = "Debug Info";
//
// Form3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button2;
this.ClientSize = new System.Drawing.Size(488, 448);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form3";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "New Record";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form3_FormClosing);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
CancelButton = button2;
ClientSize = new System.Drawing.Size(569, 404);
Controls.Add(groupBox1);
Controls.Add(button6);
Controls.Add(button4);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(textBox2);
Controls.Add(label2);
Controls.Add(textBox1);
Controls.Add(label1);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MaximizeBox = false;
MinimizeBox = false;
Name = "Form3";
ShowIcon = false;
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "New Record";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -258,16 +204,11 @@
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Label label6;
}
}

View File

@ -1,50 +1,22 @@
using ScreenCapturerNS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using ZXing;
using AForge.Video;
using AForge.Video.DirectShow;
using System.Drawing.Imaging;
namespace OTP
{
public partial class Form3 : Form
{
private string connectionString = "Data Source=key.db;Version=3;";
private bool isCapturing = false; // 添加标识截图状态的成员变量
private const string connectionString = "Data Source=key.db;Version=3;";
private bool isLocalfile = false;
private FilterInfoCollection videoDevices; // 声明用于存储摄像头设备信息的变量
private VideoCaptureDevice camera; // 声明用于摄像头捕获的变量
private bool isCameraRunning = false; // 用于标识摄像头的运行状态
private bool isScanningPaused = false;
private Bitmap previousBitmap = null;
public Form3()
{
InitializeComponent();
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
InitializeComponent(); // 确保调用了这个方法
}
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{
StopCapturing(); // 关闭窗口时停止截图
if (isCameraRunning)
{
StopCamera(); // 关闭窗口时停止摄像头
}
}
private void button1_Click(object sender, EventArgs e)
private void Button1_Click(object sender, EventArgs e)
{
try
{
@ -53,16 +25,14 @@ namespace OTP
if (!string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(secretKey))
{
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
using (SQLiteConnection connection = new(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand("INSERT INTO TotpData (Title, SecretKey) VALUES (@Title, @SecretKey)", connection))
{
command.Parameters.AddWithValue("@Title", title);
command.Parameters.AddWithValue("@SecretKey", secretKey);
command.ExecuteNonQuery();
}
using SQLiteCommand command = new("INSERT INTO TotpData (Title, SecretKey) VALUES (@Title, @SecretKey)", connection);
command.Parameters.AddWithValue("@Title", title);
command.Parameters.AddWithValue("@SecretKey", secretKey);
command.ExecuteNonQuery();
}
this.DialogResult = DialogResult.OK;
MessageBox.Show("Record added successfully.");
@ -80,68 +50,11 @@ namespace OTP
MessageBox.Show($"An error occurred: {ex.Message}");
}
}
//这里摆烂自用的怎么会犯操作上的错误主要是遇到bug不想修先晾着
//private void deactivateButton(int btn)
//{
// if (btn == 3)
// {
// button1.Enabled = false;
// button4.Enabled = false;
// button5.Enabled = false;
// button6.Enabled = false;
// }
//}
//private void activeButton()
//{
// for (int i = 1; i <= 6; i++)
// {
// string buttonName = "button" + i;
// Control[] controls = this.Controls.Find(buttonName, true);
// if (controls.Length > 0 && controls[0] is Button)
// {
// Button button = (Button)controls[0];
// button.Enabled = true;
// }
// }
//}
private void button3_Click(object sender, EventArgs e)
{
if (isCapturing)
{
label5.Text = "Stopped";
StopCapturing(); // 停止截图
}
else
{
label3.Text = "None";
label5.Text = "Running";
label4.Text = "No QR code found.";
StartCapturing(); // 开始截图
}
}
private void StartCapturing()
{
//deactivateButton(3);
isCapturing = true; // 设置截图状态为正在截图
ScreenCapturer.StartCapture((Bitmap bitmap) => {
// 进行二维码扫描
ScanQRCode(bitmap);
});
}
private void StopCapturing()
{
//activeButton();
isCapturing = false; // 设置截图状态为未截图
ScreenCapturer.StopCapture(); // 停止截图
}
private void ScanQRCode(Bitmap bitmap)
{
// 创建二维码读取器实例
BarcodeReader barcodeReader = new BarcodeReader();
var barcodeReader = new ZXing.Windows.Compatibility.BarcodeReader();
// 尝试解码二维码
Result result = barcodeReader.Decode(bitmap);
@ -149,40 +62,35 @@ namespace OTP
{
// 扫描成功,显示扫描结果
string decodedText = result.Text;
this.Invoke((MethodInvoker)(() => label3.Text = decodedText));
label3.Text = decodedText;
// 判断是否符合期望的格式
if (decodedText.StartsWith("otpauth://totp/") && decodedText.Contains("?secret="))
{
if (!isLocalfile && !isScanningPaused)
{
StopCapturing();
this.Invoke((MethodInvoker)(() => label5.Text = "Stopped"));
}
else
if (isLocalfile)
{
isLocalfile = false;
}
string[] parts = decodedText.Split(new char[] { '/', '=', '&','?' });
string[] parts = decodedText.Split(['/', '=', '&', '?']);
if (parts.Length >= 6)
{
string title = parts[3]; // 获取 title 部分
// 扫码成功
string title = Uri.UnescapeDataString(parts[3]); // 解码 title 部分
string secretKey = parts[5]; // 获取 secretKey 部分
// 在窗体上显示 title 和 secretKey
this.Invoke((MethodInvoker)(() => textBox1.Text = title));
this.Invoke((MethodInvoker)(() => textBox2.Text = secretKey));
this.Invoke((MethodInvoker)(() => label4.Text = "Success"));
//StopCamera();
textBox1.Text = title;
textBox2.Text = secretKey;
label4.Text = "Success";
}
else
{
this.Invoke((MethodInvoker)(() => label4.Text = "Invalid QR code format."));
label4.Text = "Invalid QR code format.";
}
}
else
{
this.Invoke((MethodInvoker)(() => label4.Text = "QR code format not recognized."));
label4.Text = "QR code format not recognized.";
}
}
else
@ -191,107 +99,25 @@ namespace OTP
{
label3.Text = "None";
label4.Text = "QR code not detected.";
}else if (isScanningPaused)
{
this.Invoke((MethodInvoker)(() => label3.Text = "None"));
this.Invoke((MethodInvoker)(() => label4.Text = "QR code not detected."));
}
}
}
private void button4_Click(object sender, EventArgs e)
private void Button4_Click(object sender, EventArgs e)
{
isLocalfile = true;
using (OpenFileDialog openFileDialog = new OpenFileDialog())
using OpenFileDialog openFileDialog = new();
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
string filePath = openFileDialog.FileName;
using (Bitmap image = new Bitmap(filePath))
{
ScanQRCode(image);
}
}
using Bitmap image = new(filePath);
ScanQRCode(image);
}
}
private void button5_Click(object sender, EventArgs e)
{
isScanningPaused = false;
button7.Text = "Pause";
if (isCameraRunning)
{
StopCamera(); // 停止摄像头
}else
{
StartCamera(); // 启动摄像头
}
}
private void StartCamera()
{
if (!isCameraRunning) // 添加条件检查摄像头是否已经在运行
{
if (videoDevices != null && videoDevices.Count > 0)
{
if (camera == null)
{
camera = new VideoCaptureDevice(videoDevices[0].MonikerString);
}
camera.NewFrame += Camera_NewFrame; // 注册摄像头捕获图像的事件
camera.Start(); // 启动摄像头
isCameraRunning = true; // 设置摄像头运行状态为 true
}
else
{
MessageBox.Show("No camera device found.");
}
}
}
private void StopCamera()
{
if (camera != null && camera.IsRunning)
{
camera.SignalToStop();
camera.WaitForStop();
camera.NewFrame -= Camera_NewFrame; // 取消注册摄像头捕获图像的事件
camera = null; // 将摄像头对象置为null以便下次重新创建
isCameraRunning = false; // 设置摄像头运行状态为 false
isScanningPaused = false;
button7.Text = "Pause";
}
}
private void Camera_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
if (!isScanningPaused)
{
if (previousBitmap != null)
{
previousBitmap.Dispose();
}
pictureBox1.Image = bitmap;
previousBitmap = bitmap;
}
else
{
ScanQRCode(bitmap);
bitmap.Dispose();
}
}
private void button7_Click(object sender, EventArgs e)
{
isScanningPaused = !isScanningPaused;
button7.Text = isScanningPaused ? "Resume" : "Pause";
}
private void button6_Click(object sender, EventArgs e)
private void Button6_Click(object sender, EventArgs e)
{
string clipboardText = Clipboard.GetText();
@ -299,10 +125,10 @@ namespace OTP
clipboardText.StartsWith("otpauth://totp/") &&
clipboardText.Contains("?secret="))
{
string[] parts = clipboardText.Split(new char[] { '/', '=', '&', '?' });
string[] parts = clipboardText.Split(['/', '=', '&', '?']);
if (parts.Length >= 6)
{
string title = parts[3]; // 获取 title 部分
string title = Uri.UnescapeDataString(parts[3]); // 解码 title 部分
string secretKey = parts[5]; // 获取 secretKey 部分
MessageBox.Show("OTP link successfully pasted.");

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

118
OTP/Form4.Designer.cs generated
View File

@ -1,118 +0,0 @@
namespace OTP
{
partial class Form4
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(12, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(152, 55);
this.label2.TabIndex = 1;
this.label2.Text = "label2";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(12, 119);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(216, 55);
this.label3.TabIndex = 2;
this.label3.Text = "网络时间";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(360, 55);
this.label1.TabIndex = 3;
this.label1.Text = "计算机本地时间";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(12, 174);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(152, 55);
this.label4.TabIndex = 4;
this.label4.Text = "label4";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Form4
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(705, 242);
this.Controls.Add(this.label2);
this.Controls.Add(this.label3);
this.Controls.Add(this.label1);
this.Controls.Add(this.label4);
this.Name = "Form4";
this.Text = "Troubleshooting";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form4_FormClosing);
this.Load += new System.EventHandler(this.Form4_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label4;
}
}

View File

@ -1,89 +0,0 @@
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 GuerrillaNtp;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace OTP
{
public partial class Form4 : Form
{
private NtpClient ntpClient;
private NtpClock clock;
private Timer timer;
public Form4()
{
InitializeComponent();
ntpClient = new NtpClient("time.pool.aliyun.com");
// Create and configure the timer
timer = new Timer();
timer.Interval = 1000; // 1 second interval
timer.Tick += Timer_Tick;
}
private async void Form4_Load(object sender, EventArgs e)
{
try
{
// Display local time
UpdateLocalTimeLabel();
// Query time from NTP server
clock = await ntpClient.QueryAsync();
// Display network time from NTP server
UpdateNetworkTimeLabel();
// Start the timer to update network time periodically
timer.Start();
}
catch (Exception ex)
{
// Handle any exceptions that might occur during NTP query
label4.Text = "NTP Error: " + ex.Message;
}
}
private void Timer_Tick(object sender, EventArgs e)
{
// Update the time label
UpdateLocalTimeLabel();
UpdateNetworkTimeLabel();
}
private void UpdateLocalTimeLabel()
{
DateTime localTime = DateTime.Now;
label2.Text = localTime.ToString();
}
private void UpdateNetworkTimeLabel()
{
if (clock != null)
{
DateTimeOffset networkTime = clock.UtcNow;
// Convert network time to user's local time zone
TimeZoneInfo localTimeZone = TimeZoneInfo.Local;
DateTimeOffset localTime = TimeZoneInfo.ConvertTime(networkTime, localTimeZone);
label4.Text = localTime.ToString();
}
}
// Form4 closing event
private void Form4_FormClosing(object sender, FormClosingEventArgs e)
{
// Stop the timer when the form is closing
timer.Stop();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,20 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{698CAA40-B8B1-4576-9F2F-305BD7522771}</ProjectGuid>
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>OTP</RootNamespace>
<AssemblyName>OTP</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -30,184 +17,31 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup>
<StartupObject>OTP.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<AssemblyVersion>1.0.0.1</AssemblyVersion>
<FileVersion>1.0.0.1</FileVersion>
<Authors>Chenx221</Authors>
<Version>1.0.0.1</Version>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<Reference Include="AForge, Version=2.2.5.0, Culture=neutral, PublicKeyToken=c1db6ff4eaa06aeb, processorArchitecture=MSIL">
<HintPath>..\packages\AForge.2.2.5\lib\AForge.dll</HintPath>
</Reference>
<Reference Include="AForge.Video, Version=2.2.5.0, Culture=neutral, PublicKeyToken=cbfb6e07d173c401, processorArchitecture=MSIL">
<HintPath>..\packages\AForge.Video.2.2.5\lib\AForge.Video.dll</HintPath>
</Reference>
<Reference Include="AForge.Video.DirectShow, Version=2.2.5.0, Culture=neutral, PublicKeyToken=61ea4348d43881b7, processorArchitecture=MSIL">
<HintPath>..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll</HintPath>
</Reference>
<Reference Include="CircularProgressBar, Version=2.8.0.16, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<HintPath>..\packages\CircularProgressBar.2.8.0.16\lib\net40\CircularProgressBar.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="GuerrillaNtp, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GuerrillaNtp.3.1.0\lib\netstandard2.0\GuerrillaNtp.dll</HintPath>
</Reference>
<Reference Include="Otp.NET, Version=1.3.0.0, Culture=neutral, PublicKeyToken=38a48df817e173a6, processorArchitecture=MSIL">
<HintPath>..\packages\Otp.NET.1.3.0\lib\net45\Otp.NET.dll</HintPath>
</Reference>
<Reference Include="ScreenCapturer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ScreenCapturer.3.0.1\lib\netstandard2.0\ScreenCapturer.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.Direct3D11.4.2.0\lib\net45\SharpDX.Direct3D11.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.118.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Drawing.Common, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.7.0.0\lib\net462\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WinFormAnimation, Version=1.6.0.4, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<HintPath>..\packages\WinFormAnimation.1.6.0.4\lib\net40\WinFormAnimation.dll</HintPath>
</Reference>
<Reference Include="zxing, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.dll</HintPath>
</Reference>
<Reference Include="zxing.presentation, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.presentation.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="Form3.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form3.Designer.cs">
<DependentUpon>Form3.cs</DependentUpon>
</Compile>
<Compile Include="Form4.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form4.Designer.cs">
<DependentUpon>Form4.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form2.resx">
<DependentUpon>Form2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form3.resx">
<DependentUpon>Form3.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form4.resx">
<DependentUpon>Form4.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="empty_key.db" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
@ -224,15 +58,29 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
</Target>
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<ItemGroup>
<PackageReference Include="Otp.NET" Version="1.4.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Data.SQLite" Version="1.0.118.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118.0" />
<PackageReference Include="System.Data.SQLite.EF6" Version="1.0.118.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="ZXing.Net" Version="0.16.9" />
<PackageReference Include="ZXing.Net.Bindings.Windows.Compatibility" Version="0.16.12" />
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OTP

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("OTP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Chenx221")]
[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")]

View File

@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace OTP.Properties
{
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
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.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
{
public static Settings Default {
get {
return defaultInstance;
}
}

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AForge" version="2.2.5" targetFramework="net481" />
<package id="AForge.Video" version="2.2.5" targetFramework="net481" />
<package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net481" />
<package id="CircularProgressBar" version="2.8.0.16" targetFramework="net481" />
<package id="EntityFramework" version="6.4.4" targetFramework="net481" />
<package id="GuerrillaNtp" version="3.1.0" targetFramework="net481" />
<package id="Otp.NET" version="1.3.0" targetFramework="net481" />
<package id="ScreenCapturer" version="3.0.1" targetFramework="net481" />
<package id="SharpDX" version="4.2.0" targetFramework="net481" />
<package id="SharpDX.Direct3D11" version="4.2.0" targetFramework="net481" />
<package id="SharpDX.DXGI" version="4.2.0" targetFramework="net481" />
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.118.0" targetFramework="net481" />
<package id="System.Buffers" version="4.5.1" targetFramework="net481" />
<package id="System.Data.SQLite" version="1.0.118.0" targetFramework="net481" />
<package id="System.Data.SQLite.Core" version="1.0.118.0" targetFramework="net481" />
<package id="System.Data.SQLite.EF6" version="1.0.118.0" targetFramework="net481" />
<package id="System.Data.SQLite.Linq" version="1.0.118.0" targetFramework="net481" />
<package id="System.Drawing.Common" version="7.0.0" targetFramework="net481" />
<package id="System.IO" version="4.3.0" targetFramework="net481" />
<package id="System.Memory" version="4.5.5" targetFramework="net481" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net481" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net481" />
<package id="WinFormAnimation" version="1.6.0.4" targetFramework="net481" />
<package id="ZXing.Net" version="0.16.9" targetFramework="net481" />
</packages>

View File

@ -1,3 +1,9 @@
# OTP
这是一个不太靠谱的适用于Windows平台的二步验证代码生成器
这是一个适用于Windows平台的二步验证代码生成器
可满足基本TOTP验证器需求
------
<img src="https://git.chenx221.cyou/chenx221/OTP/raw/branch/net8.0/img/2024-08-22_201918.png">

BIN
img/2024-08-22_201918.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB