views:

101

answers:

1

I have been thinking of ways I could uniquely identify a computer in python. First, I thought about checking the user's mac address and hard disk space, then I tried to compute some sort of rating from many of these variables. However, this solution doesn't feel right. It takes a long time to run and I had to change it many times already due to unforeseen errors.

Ideas?? Additionally, it would be very nice if it could detect running on a virtual machine.

+7  A: 

First you need to define "computer." Is a computer the same computer if you change the case? The hard drive? The network card? Increase the RAM? Upgrade the kernel?

(It brings to mind the saying about "my grandfather's hammer" — sure, I've replaced the head five times and the handle twice, but it's still the same hammer...)

It helps to step back and identify why you need to do this. The solution might be to put a configuration file somewhere with a random key in it, and then if the user needs to absolutely nuke this identifying cookie for whatever reason, they can. (Or maybe you don't want that...)

You might find the Python UUID module useful too.

detly
To add to detly's suggestion, note the Python standard library has a uuid module that would be ideal for generating a unique id for a host.
Rakis
I wasn't familiar with this module. Thanks. It makes my life easier.
relima