2

Possible Duplicate:
Reliable way of generating unique hardware ID

I would like to retrieve an unique hardware identifier for a single machine in C++. Any suggestions? I need this software working in Windows XP, Vista, 7, 8. I just need a few system calls to retrieve MAC address, hard disk serial number, or something like this.

Community
  • 1
  • 1
Didac Perez Parera
  • 3,734
  • 3
  • 52
  • 87
  • 1
    What are you going to use it for? That will change what values are okay to use. A MAC address will be unique in normal use, but it can easily be changed to something that is not unique if the user desires. – Dirk Holsopple Oct 24 '12 at 15:02
  • Here's a simplified version of the CodeProject article, that uses C# and WMI to basically compile the HUID using machine's hardware specs. It should be fairly easy to translate it into C: http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer?msg=4156672#xx4156672xx – ahmd0 Mar 25 '16 at 22:22

2 Answers2

3

Encrypt any value with the machine's DPAPI key and use the encrypted value as your ID.

Note: I copied my original answer to the question that this one duplicates.

Community
  • 1
  • 1
ixe013
  • 9,559
  • 3
  • 46
  • 77
  • DPAPI will use PBKDF2 encryption method that uses random "salt", which will produce a resulting cipher text with random values every time you generate it. So unless you specify how to make PBKDF2 not use random "salt" (I'm guessing, via CryptProtectData API) I don't see how your suggestion would work? More info: https://msdn.microsoft.com/en-us/library/ms995355.aspx – ahmd0 Mar 25 '16 at 22:18
0

Here is a great article on how to get your mac address using C++. You could use one of those three methods of getting your MAC address, after which you could use some sort of encryption (eh sha256) on these MAC address -- that is of course, only if you want these MAC address to be hidden while you store them.

Florin Stingaciu
  • 8,085
  • 2
  • 24
  • 45