Generate unique hardware id - Cross platform
-
Hi. Dose Qt have any reference to generate a unique hardware id?!
If not, please submit a code of pure C++!Thanks.
-
@AliReza-Beytari
No, since there is no generic way to do so.But you should be able to get the MAC address (which can get easily spoofed by the user though) and/or CPU id (shouldn't be too hard to get on various systems.
-
@AliReza-Beytari
Maybe this can help: http://doc.qt.io/qt-5.7/quuid.html -
@beecksche
this generates a random unique ID. So creating such ID multiple times on the same machine creates different IDs, which is not desired. -
What one usually does is to put a bunch of hardware ids (macs, cpu id, mb id) together, as @raven-worx suggested, and then to run a hash function over them (e.g. sha1). However, generating such identifiers is a pretty suspicious design in my opinion, as any change in the used (for ids) hardware will break the id matching.
-
@kshegunov said:
However, generating such identifiers is a pretty suspicious design in my opinion, as any change in the used (for ids) hardware will break the id matching.
which may be the goal after all ;)
-
@raven-worx said:
which may be the goal after all
Okay, I haven't thought about that ... it might be. :)
-
Hi to all
As of Qt 5.11 there is a static function in QSysInfo class:
QByteArray QSysInfo::machineUniqueId()
https://doc.qt.io/qt-5/qsysinfo.html#machineUniqueId