private static int getMachineCode() { // * Copyright (C) 2012 Artem Los, All rights reserved. // * // * This code will generate a 5 digits long key, finger print, of the system // * where this method is being executed. However, that might be changed in the // * hash function "GetStableHash", by changing the amount of zeroes in // * MUST_BE_LESS_OR_EQUAL_TO to the one you want to have. Ex 1000 will return // * 3 digits long hash. methods m = new methods(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); string collectedInfo = ""; collectedInfo += System.Environment.MachineName; var x = new List <string>(); foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { // probably need to do some filtering on ni.NetworkInterfaceType here //collectedInfo +=ni.GetPhysicalAddress(); x.Add(ni.GetPhysicalAddress().ToString()); } x.Sort(); collectedInfo += x[x.Count - 1]; x.Clear(); foreach (ManagementObject wmi_HD in searcher.Get()) { // get the hardware serial no. if (wmi_HD["SerialNumber"] == null && wmi_HD["Removable"] == null && wmi_HD["Replaceable"] == null) { // Don't add } else { //serialNo = wmi_HD["SerialNumber"].ToString(); //hotSwap = Convert.ToBoolean(wmi_HD["HotSwappable"]); //Console.WriteLine(hotSwap); x.Add(wmi_HD["SerialNumber"].ToString()); } } x.Sort(); collectedInfo += string.Join("", x); return(m.getEightByteHash(collectedInfo, 100000)); }
private static int getMachineCode() { // * Copyright (C) 2012 Artem Los, All rights reserved. // * // * This code will generate a 5 digits long key, finger print, of the system // * where this method is being executed. However, that might be changed in the // * hash function "GetStableHash", by changing the amount of zeroes in // * MUST_BE_LESS_OR_EQUAL_TO to the one you want to have. Ex 1000 will return // * 3 digits long hash. methods m = new methods(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); string collectedInfo = ""; collectedInfo += System.Environment.MachineName; var x = new List<string>(); foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { // probably need to do some filtering on ni.NetworkInterfaceType here //collectedInfo +=ni.GetPhysicalAddress(); x.Add(ni.GetPhysicalAddress().ToString()); } x.Sort(); collectedInfo += x[x.Count - 1]; x.Clear(); foreach (ManagementObject wmi_HD in searcher.Get()) { // get the hardware serial no. if (wmi_HD["SerialNumber"] == null && wmi_HD["Removable"] == null && wmi_HD["Replaceable"] == null) { // Don't add } else { //serialNo = wmi_HD["SerialNumber"].ToString(); //hotSwap = Convert.ToBoolean(wmi_HD["HotSwappable"]); //Console.WriteLine(hotSwap); x.Add(wmi_HD["SerialNumber"].ToString()); } } x.Sort(); collectedInfo += string.Join("", x); return m.getEightByteHash(collectedInfo, 100000); }