• Tools


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

    只有不断学习,才可进步。
  • 相关阅读:
    递归方法:对于树形结构的表,根据当前数据获取无限极的父级名称
    P
    A
    今年暑假不AC1
    J
    今年暑假不AC
    A
    *max_element函数和*min_element函数
    1199: 房间安排
    素数
  • 原文地址:https://www.cnblogs.com/onlyforliu/p/5770402.html
Copyright © 2020-2023  润新知