码迷,mamicode.com
首页 > 其他好文 > 详细

Tools

时间:2016-08-14 17:33:11      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management.Instrumentation;
using System.Management;

namespace goggb
{
class Tools
{
public static string getUUID()
{
string test=GetCpuID()+GetMacAddress();
string Encrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(test, "MD5").ToLower();
return Encrypt;
}
public static string GetCpuID()
{
//Get the first CPU 16 bits ID
var strCpuID = string.Empty;
try
{
var mc = new ManagementClass("Win32_Processor");
var moc = mc.GetInstances();
foreach (var mo in moc)
{
strCpuID = mo.Properties["ProcessorId"].Value.ToString();
break;
}
return strCpuID;
}
catch
{
return string.Empty;
}
}
public static string GetMacAddress()
{
var mac = string.Empty;
try
{
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
var moc = mc.GetInstances();
foreach (var mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
{
mac = mo["MacAddress"].ToString();
break;
}
}
return mac;
}
catch
{
return string.Empty;
}
}
}
}

Tools

标签:

原文地址:http://www.cnblogs.com/onlyforliu/p/5770402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!