שתף באמצעות


Unique PC Identity for License key generator

Question

Friday, June 15, 2012 6:20 AM

I have been searching the web for unique PC Identity info

I have come across CPU id & Hard Disk serial number

Are these two identities always present & are they always unique

Are there minimum & maximum data lengths for each

I can create encrypted keys from these & get the installer to forward me the keys so I can generate a license key

Any help much appreciated

All replies (12)

Friday, June 15, 2012 8:04 AM ✅Answered

If all you need is something that is unique to each installation then you could use the time - your chance of two users installating the application at the exact same instant would be fairly small.   Or, just use a large pseudo-random number - you can calculate how large it needs to be for the chance of a duplication to be close enough to zero for your purpose.


Friday, June 15, 2012 6:37 AM

No both are depending from the brand and type of CPU and disk

Especially a CPU id is rare but a disk Id is also seldom returned.

Be aware that because of this kind of ID's once a then major company (then likewise Microsoft) has been broken because the disk which they supported was not anymore available. 

You need for this kind of ID's a 24/7 real online support otherwise customers can sue you because your program is malfunctioning because of hardware problems . 

Success
Cor


Friday, June 15, 2012 7:39 AM

Thanks for the reply, however I have a trick I did not want to reveal as to how I would use this information

I would only need the user to give this information once to obtain the key, then program will run on any machine thereafter (with some qualification by the purchaser), but I need a unique identity on the first install machine, then it is never needed again.

This process will ensure it cannot be installed on another computer unless it is reverse engineered. (yes I am sure my process is foolproof & the license key cannot be copied for another machine)

So my original question still is what I want to know for sure, is there a unique identity I can use only once on install & never need again, by install I mean first run of my program to validate the licence I have given them after they identify their computer id (encrypted by manipulation of say CPU id) to me & I return a license key


Friday, June 15, 2012 8:40 AM

Excellent idea although I would have to create a temp with that data in on first run, then validate when key is returned, then delete the temp file

Will be back in 12-15 hours, thanks


Friday, June 15, 2012 11:44 AM

The Mac address of a network adapter is unique however while an actual physical MAC address cannot be changed in hardware, the address can be emulated in software. This process is called cloning. And if the hardware fails the address is changed by the installation of replacement hardware.

The list below summarizes options to find a computer's MAC address:

  • Windows: ipconfig /all, or winipcfg
  • Linux and some Unix: ifconfig -a
  • Mac with Open Transport: TCP/IP Control Panel - Info or User Mode/Advanced
  • Mac with MacTCP: TCP/IP Control Panel - Ethernet icon

MAC addresses are 12-digit hexadecimal numbers (48 bits in length). By convention, MAC addresses are usually written in one of the following two formats:

<tt>MM:MM:MM:SS:SS:SS</tt>

<tt>MM-MM-MM-SS-SS-SS</tt>

The first half of a MAC address contains the ID number of the adapter manufacturer. These IDs are regulated by an Internet standards body. The second half of a MAC address represents the serial number assigned to the adapter by the manufacturer. In the example,

<tt>00:A0:C9:14:C8:29</tt>

The prefix

<tt>00A0C9</tt>

indicates the manufacturer is Intel Corporation.

You've taught me everything I know but not everything you know.


Friday, June 15, 2012 12:04 PM

Why not just use a GUID?

http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx

I hate hardware based keys. That is unless multiple devices are used to identify the computer. If you don't do this the software stops working when the user's hardware is changed.

Paul ~~~~ Microsoft MVP (Visual Basic)


Saturday, June 16, 2012 10:10 PM

Thanks for all replies, All I need is a unique identifier from the time the user first runs the program to get an encrypted key to send to me then when I return the license key there is a match (using the time will need a temp file or store in my data base temporarily, which is tedious and untidy coding)

From that point where the license key is validated,  the identifier is not needed anymore

GUID are only useful once, not the same 2nd time generated

There also seems to be a problem with MAC addresses from web sample codes I have seen, unless someone can point me to the Unique MAC address for the computer (not other devices)


Saturday, June 16, 2012 10:31 PM

Also the code I have found (2 versions) and using returns no information re a MAC address

Public Function GetMACAddress() As String
        Dim mc As 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 = [String].Empty Then
                ' only return MAC Address from first card
                If CBool(mo("IPEnabled")) = True Then
                    MACAddress = mo("MacAddress").ToString()
                End If
            End If
            mo.Dispose()
        Next

        MACAddress = MACAddress.Replace(":", "")
        Return MACAddress
    End Function

or

Public Function getMacAddress() As String
    Dim cpuID As String = String.Empty
    Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
    Dim moc As ManagementObjectCollection = mc.GetInstances()
    For Each mo As ManagementObject In moc
      If (cpuID = String.Empty And CBool(mo.Properties("IPEnabled").Value) = True) Then
        cpuID = mo.Properties("MacAddress").Value.ToString()
      End If
    Next
    Return cpuID
  End Function


Saturday, June 16, 2012 10:45 PM

A GUID is simply a very large (16 bytes) psuedo-random number - it is probably larger than you need, but generating it is relatively easy, and you can assume there are good controls to ensure it is as unique as possible.  You do need to check that it isn't all zeroes.

The MAC has a higher likelihood of being duplicated, but it has the benefit that you can assume it is constant between request and registration. However, like a file stored on disk, it could be moved between machines and it could be faked.


Sunday, June 17, 2012 2:20 AM

Make a huge random number

Option Strict On
Imports System.Security.Cryptography
Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim rngCsp As New RNGCryptoServiceProvider()
        Dim randomNumber(127) As Byte
        rngCsp.GetBytes(randomNumber) ' use GetNonZeroBytes if desired
        For Each b As Byte In randomNumber
            TextBox1.AppendText(b.ToString("X2"))
        Next
    End Sub
End Class

Sunday, June 17, 2012 2:42 AM

Both of those functions work fine here, just needs a reference to System.Management


Sunday, June 17, 2012 7:09 AM

Thanks for all contributions, have decided on using Acamars suggestion re time & have found a convenient way to store the time until license key is activated, it is then discarded