Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string GetDeviceUniqueIdentifier()
- {
- string ret = string.Empty;
- string concatStr = string.Empty;
- try
- {
- ManagementObjectSearcher searcherBb = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
- foreach (var obj in searcherBb.Get())
- {
- concatStr += (string)obj.Properties["SerialNumber"].Value ?? string.Empty;
- }
- ManagementObjectSearcher searcherBios = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
- foreach (var obj in searcherBios.Get())
- {
- concatStr += (string)obj.Properties["SerialNumber"].Value ?? string.Empty;
- }
- ManagementObjectSearcher searcherOs = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
- foreach (var obj in searcherOs.Get())
- {
- concatStr += (string)obj.Properties["SerialNumber"].Value ?? string.Empty;
- }
- var sha1 = SHA1.Create();
- ret = string.Join("", sha1.ComputeHash(Encoding.UTF8.GetBytes(concatStr)).Select(b => b.ToString("x2")));
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement