I found a little project online where they get:
- Processor ID
- Motherboard ID
- Volume serial ID
- Mac address ID
They then hash it through MD5 but it is depreciated now so best bet is do the same and hash it through Sha512
First you'll need to import and reference if not done automatically:
Imports System.Management
Imports System.Security.Cryptography
Imports System.Text
Then the function get HWID (HardwareID)
Public Function Get_HWID() As String
'Information Handler
Dim hw As New clsComputerInfo
'Decalre variables
Dim hdd, cpu, mb, mac As String
'Get all the values
cpu = hw.GetProcessorId()
hdd = hw.GetVolumeSerial("C")
mb = hw.GetMotherBoardID()
mac = hw.GetMACAddress()
'Generate the hash
Dim hwid As String = GenerateSHA512String(cpu & hdd & mb & mac)
Return hwid
End Function
Function to generate Hash:
Public Shared Function GenerateSHA512String(ByVal inputString) As String
Dim sha512 As SHA512 = SHA512Managed.Create()
Dim bytes As Byte() = Encoding.UTF8.GetBytes(inputString)
Dim hash As Byte() = sha512.ComputeHash(bytes)
Dim stringBuilder As New StringBuilder()
For i As Integer = 0 To hash.Length - 1
stringBuilder.Append(hash(i).ToString("X2"))
Next
Return stringBuilder.ToString()
End Function
And finally Class to get the information:
Public Class clsComputerInfo
Friend Function GetProcessorId() As String
Dim strProcessorId As String = String.Empty
Dim query As New SelectQuery("Win32_processor")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strProcessorId = info("processorId").ToString()
Next
Return strProcessorId
End Function
Friend Function GetMACAddress() As String
Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
Dim MACAddress As String = String.Empty
For Each mo As ManagementObject In moc
If (MACAddress.Equals(String.Empty)) Then
If CBool(mo("IPEnabled")) Then MACAddress = mo("MacAddress").ToString()
mo.Dispose()
End If
MACAddress = MACAddress.Replace(":", String.Empty)
Next
Return MACAddress
End Function
Friend Function GetVolumeSerial(Optional ByVal strDriveLetter As String = "C") As String
Dim disk As ManagementObject = New ManagementObject(String.Format("win32_logicaldisk.deviceid=""{0}:""", strDriveLetter))
disk.Get()
Return disk("VolumeSerialNumber").ToString()
End Function
Friend Function GetMotherBoardID() As String
Dim strMotherBoardID As String = String.Empty
Dim query As New SelectQuery("Win32_BaseBoard")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get()
strMotherBoardID = info("SerialNumber").ToString()
Next
Return strMotherBoardID
End Function
End Class
I reviewed the code of this project
Hope this can help you and please remember add the reference to Management
More Information:
Most common IDs used for HWID are: CPU ID and MAC address based hardware ID and Hard Drive serial number
HWID are not recommended as a licencing system as it isn't accurate and not practical if the user changes computer or formats the drives etc. It is more recommended to use a certificate system or more complex authentification.