I managed to check the first part on my Android device and create an arbitrary number on every new python run, so it is not applicable for this purpose.
The second type of problem drowned itself, because if in the documents he mentioned that he can return any one of them , then this is not something you could rely on (+ I could not find a machine on which I could test it) . A good netifaces package came to the rescue, which does a similar thing
netifaces.interfaces() # returns eg ['lo', 'eth0', 'tun2'] netifaces.ifaddresses('eth0')[netifaces.AF_LINK] # returns [{'addr': '08:00:27:50:f2:51', 'broadcast': 'ff:ff:ff:ff:ff:ff'}]
However, I rather refused to use MAC addresses, I got something more stable.
Now to the identifiers:
1) Windows:
Doing this and getting the output can be quite good:
wmic csproduct get UUID
or the one I used and is available in the registry ( HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography ):
import _winreg registry = _winreg.HKEY_LOCAL_MACHINE address = 'SOFTWARE\\Microsoft\\Cryptography' keyargs = _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY key = _winreg.OpenKey(registry, address, 0, keyargs) value = _winreg.QueryValueEx(key, 'MachineGuid') _winreg.CloseKey(key) unique = value[0]
2) Linux:
/sys/class/dmi/id/board_serial
or
/sys/class/dmi/id/product_uuid
or if not root:
cat /var/lib/dbus/machine-id
3) Android:
If you are working with python and don't want to interfere with the Java stuff, this should work very well:
import subprocess cmd = ['getprop', 'ril.serialnumber'] self.unique = subprocess.check_output(cmd)[:-1]
but if you like Java, then skip this answer , although even ANDROID_ID uniqueness is quite debatable, if it allowed to change, so, most likely, the serial number is a safer bet.
Note that, as mentioned in the linked answer, even ril.serialnumber can be empty or empty or missing (missing key). The same thing happens with the official Android API , where he clearly stated this:
The serial number of the equipment , if available.
Mac / iPhone: I could not find any solution, because I do not have access to them, but if there is a variable containing the value of the machine identifier, then you can get a simple subprocess.check_output()