资源简介
能够获取CPU序列号和硬盘序列号并且进行MD5的加密生成一个机器码
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Security;
using System.Web.Configuration;
namespace Kingbo.Detonator.LicenseTool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender EventArgs e)
{
this.Close();
}
private void button1_Click(object sender EventArgs e)
{
try
{
GetInfo getInfo = new GetInfo();
List cpuList = getInfo.GetCPUInfo();
List hdList = getInfo.GetHardDiskInfo();
//List networkList = getInfo.GetbaseBoard();
foreach (string str in cpuList)
{
this.richTextBox1.AppendText(str + “\r\n“);
}
foreach (string str in hdList)
{
this.richTextBox2.AppendText(str + “\r\n“);
}
//foreach (string str in networkList)
//{
// this.richTextBox3.AppendText(str + “\r\n“);
//}
string cpuId = cpuList.Count > 0 ? cpuList[0] : ““;
string hardDiskId = hdList.Count > 0 ? hdList[0] : ““;
string id_key = string.Format(“{0}_{1}“ cpuId hardDiskId);
string key = encryptMachineInfo(id_key);
this.richTextBox4.AppendText(key + “\r\n“);
//string hdStr = getInfo.GetDiskVolume(“c“);
//this.richTextBox4.AppendText(“\r\n“ + hdStr);
}
catch(Exception ex){
MessageBox.Show(ex.StackTrace);
}
}
///
/// 对机器码信息进行加密
///
///
///
public static string encryptMachineInfo(string plainText)
{
string encryptText = ““;
if (plainText == null || plainText.Trim().Length == 0) return encryptText;
encryptText = FormsAuthentication.HashPasswordForStoringInConfigFile(plainText + “#Kingbo Technology Limited#“ FormsAuthPasswordFormat.SHA1.ToString());
encryptText += FormsAuthentication.HashPasswordForStoringInConfigFile(plainText + “#Kingbo Technology Limited#“ FormsAuthPasswordFormat.MD5.ToString());
return encryptText;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 144 2013-10-29 10:55 app.config
文件 2733 2013-10-30 23:17 Form1.cs
文件 6469 2013-10-30 23:15 Form1.Designer.cs
文件 5817 2013-10-30 23:15 Form1.resx
文件 5993 2013-10-30 15:36 GetInfo.cs
文件 14317 2013-10-30 15:30 HardDiskInfo.cs
文件 3938 2013-10-30 15:31 LicenseTool.csproj
文件 227 2013-10-30 15:31 LicenseTool.csproj.user
文件 509 2013-10-29 11:11 Program.cs
文件 1354 2013-10-29 10:19 Properties\AssemblyInfo.cs
文件 2896 2013-10-29 10:55 Properties\Resources.Designer.cs
文件 5612 2013-10-29 10:19 Properties\Resources.resx
文件 1128 2013-10-29 10:55 Properties\Settings.Designer.cs
文件 249 2013-10-29 10:19 Properties\Settings.settings
- 上一篇:ACS800整流侧手册
- 下一篇:状态反馈线性二次型最优控制器设计
评论
共有 条评论