EI-Image-Viewer-Api/EI_Image_Viewer_Activation/Main.cs

46 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EI_Image_Viewer_Activation
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void btnCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(activeSecreteTbox.Text);
MessageBox.Show("拷贝成功!");
}
private void codeTBox_TextChanged(object sender, EventArgs e)
{
this.activeSecreteTbox.Text = Md5($"{this.codeTBox.Text.Trim()}_XINGCANG");
}
public static string Md5(string target)
{
using (MD5 md5 = MD5.Create())
{ // MD5非线程安全
byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(target));
StringBuilder sb = new StringBuilder(32);
for (int i = 0; i < bytes.Length; ++i)
sb.Append(bytes[i].ToString("x2"));
return sb.ToString();
}
}
}
}