Results 1 to 5 of 5

Thread: Manufactures HDD Factory Serial Number

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    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

  2. #2
    Lively Member
    Join Date
    Jul 2007
    Posts
    85

    Re: Manufactures HDD Factory Serial Number

    You could calculate a MD5 hash of the serial number.

    vb.net Code:
    1. Dim md5 As New Security.Cryptography.MD5CryptoServiceProvider
    2.      Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
    3.     bytesToHash = md5.ComputeHash(bytesToHash)
    4.     Dim strResult As String = ""
    5.     For Each b As Byte In bytesToHash
    6.         strResult += b.ToString("x2")
    7.     Next
    That will output it in hex, if you need integers you could output the octets in integers instead

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    Re: Manufactures HDD Factory Serial Number

    Thank you..Im a bit stuck. What do you mean by octets?

  4. #4
    Lively Member
    Join Date
    Jul 2007
    Posts
    85

    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:
    1. Dim strToHash As String = "Serial123456"
    2.         Dim md5 As New Security.Cryptography.MD5CryptoServiceProvider
    3.         Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
    4.         bytesToHash = md5.ComputeHash(bytesToHash)
    5.         Dim strResult As String = ""
    6.         For Each b As Byte In bytesToHash
    7.             strResult += CStr(CInt(b))
    8.         Next
    9.         MessageBox.Show(strResult)

    This outputs strResult = "281031269341751861721413219519858265569"
    The Hex version would be strResult = "1c677e0922afbaac0e84c3c63a1a3745"
    Last edited by Nihilistic Mystic; Jan 11th, 2008 at 02:30 PM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    228

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width