Unique Hardware ID

Hello everyone,

I’ve been busy quite a while, looking for a way to make a unique hardware-related key, not one that is the same when installed on a same type of computer (like in an office).

For this I found the OS module getting close, being able to access basic information of the PC it’s running on. However I would like to access something more unique, like a MAC-address, harddisk-ID, and more like those unique values.

Besides how to get that, I’m also wondering how the OS module works with other types of windows (95, 98,NT, 2000, etc).

Help will really be appreciated!

MAC Address is pretty much what is guaranteed to be unique, assuming the pc has a network connection. It should be in the System module

I have created such keys by referencing the time date, disk free space and name of computer. Combine them all together, even on a Ghost restored machine you will get a unique string. no computer program runs ever at the same exact time.

I tried and searched for that function in the system-module, but it’s not there, neither in de os-module. Thanks for the advice anyway! If I create time-sensitive, freespace, or any other form of random ID (which has then to be stored), it is impossible to track where that stored version comes from. You can copy such an ID, and use it together with a key on another computer relatively easy I think.

What I found until now did not really satisfy me yet, but I will name them:

  1. parse the output of ‘ipconfig /all’
  2. Install extra module, like ‘pyWin32’

I went for the last one, namely the Harddisk-ID (not volume-ID), since the HD (with the OS on it) is one of the most stable factors. I skipped the MAC address, because ethernet adapters are easier to turn off (I do sometimes, to kickstart my lousy connection), than a bootdisk ;), But if needed, it is possible to include it via the pyWin32 module.

Thx for the help, and hope this helps for others.

For the interested (Install pyWin32 first!), code I use for Hardware-ID of a harddisk:

import win32api
import math
path = str(win32api.GetSystemDirectory().split('\\')[0]) + "\\" #use the Bootdisk
serial = win32api.GetVolumeInformation(path)[1] #is a Negative number (long), always the case?
serial = int(math.sqrt(int(serial**2))) #make it always positive

For those looking for the MAC-address via pyWin32: