SCENARIO
I would like to learn, in C # or VB.NET , how to create a hardware identifier. based on the same methodology that Microsoft developers do for this.
First of all, before continuing, I have to advertise this question, this is a more specific other question arising from this other question: Get hardware identifiers such as Microsoft .
And the main problems for creating Microsoft HWID, based on the SMBIOS table , are described in the answers to this question, related above, and more deeply here: Specifying computer hardware identifiers
And my reason for trying to reproduce their methodology is simply to follow professional standard guidelines on how to do the right thing: Microsoft's way.
PROBLEM
Since getting the SMBIOS table from managed .NET seems an impossible / unrealized task, I also cannot find any demo using the Win32 function: GetSystemFirmwareTable , and somehow parsing the SMBIOS table seems like a real nightmare that works too much for one one developer .... because I suspect that the working analyzer algorithm will need to be constantly updated / updated: SMBIOS version history
... , WMI (SMBIOS), WMI null, WMI) , Microsoft HWID.
, Microsoft, HWID, : SMBIOS.
, - , , ...
, , :
( HWID URL-, SCENARIO), )
UUID 5 (SHA-1) 70ffd812-4c7f-4c7d-0000-000000000000
... , , cypher?. , SHA-1. SHA1CryptoServiceProvider , ... .
, , :
#:
string manufacturer = "American Megatrends Inc.";
byte[] charBuff = Encoding.Unicode.GetBytes(manufacturer);
byte[] hashBuff = null;
string hashStr = null;
using (SHA1CryptoServiceProvider cypher = new SHA1CryptoServiceProvider()) {
hashBuff = cypher.ComputeHash(charBuff);
hashStr = BitConverter.ToString(hashBuff).Replace("-", "");
}
Debug.WriteLine("SHA-1=\"{0}\"", hashStr);
Guid guid = new Guid(hashBuff);
VB.NET:
Dim manufacturer As String = "American Megatrends Inc."
Dim charBuff As Byte() = Encoding.Unicode.GetBytes(manufacturer) ' UTF-16
Dim hashBuff As Byte()
Dim hashStr As String
Using cypher As New SHA1CryptoServiceProvider
hashBuff = cypher.ComputeHash(charBuff)
hashStr = BitConverter.ToString(hashBuff).Replace("-", "") ' Same string conversion methodology employed in a MSDN article.
End Using
Debug.WriteLine("SHA-1=""{0}""", hashStr) ' SHA-1="0E74E534EE9F1985AE173C640302F58121190593"
Dim guid As New Guid(hashBuff) ' System.ArgumentException: 'Byte array for GUID must be exactly 16 bytes long.'
GUID GUID, ComputerHardwareIds.exe :
{035a20a6-fccf-5040-bc3e-b8b794c57f52} < -
, ... , ?