Manufactures HDD Factory Serial Number
At the moment im getting the Volume serial number that windows gives you. So every time a pc has been formatted the serial number is different. I'm getting the volume serial number and doing an alogarithm for activation purpose. Every time windows has been installed the serial will be different. this is the code to get the Manufactures Factory serial off the HDD.
Code:
Dim mgmclass As New System.Management.ManagementClass("Win32_PhysicalMedia")
Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances()
Dim mgmenum As Management.ManagementObjectCollection.ManagementObjectEnumerator = mgmcoll.GetEnumerator
mgmenum.MoveNext()
TextBox1.Text = (mgmenum.Current.Properties("SerialNumber").Value.ToString)
The serial number has letters and numbers. I need to convert it to all numbers so i can do the alogarithm. Is there a way i can do this.
Regards
Gerald
Re: Manufactures HDD Factory Serial Number
You could calculate a MD5 hash of the serial number.
vb.net Code:
Dim md5 As New Security.Cryptography.MD5CryptoServiceProvider
Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
bytesToHash = md5.ComputeHash(bytesToHash)
Dim strResult As String = ""
For Each b As Byte In bytesToHash
strResult += b.ToString("x2")
Next
That will output it in hex, if you need integers you could output the octets in integers instead
Re: Manufactures HDD Factory Serial Number
Thank you..Im a bit stuck. What do you mean by octets?
Re: Manufactures HDD Factory Serial Number
The MD5 algorithm returns 16 bytes (octets) into the byte array. The line
strResult += b.ToString("x2")
takes each byte as the for loop iterates though them, converts it to Hex and adds it to a string.
If you want just a long string of Integers you could do something like this.
vb.net Code:
Dim strToHash As String = "Serial123456"
Dim md5 As New Security.Cryptography.MD5CryptoServiceProvider
Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
bytesToHash = md5.ComputeHash(bytesToHash)
Dim strResult As String = ""
For Each b As Byte In bytesToHash
strResult += CStr(CInt(b))
Next
MessageBox.Show(strResult)
This outputs strResult = "281031269341751861721413219519858265569"
The Hex version would be strResult = "1c677e0922afbaac0e84c3c63a1a3745"
Re: Manufactures HDD Factory Serial Number
Thank you. this is what im going to use for the activation. Get the manufactures Serial from the hdd. Convert it to a number and then take the 1st 12 numbers out of the serial(encryption).