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;
}
}
}
}