Generating Unique Keys

Mongryong Mongryong at sympatico.ca
Sat Jan 25 18:29:12 CET 2003


Right now, I mainly need a way to generate unique (web) session keys. 
However, it would be nice to have a general purpose function for
generating unique keys.

For session keys, is their a way in Python to grap a client's MAC
address.  If so, is there any security concern with using a client's MAC
address?

Thanks.

On Sat, 2003-01-25 at 11:48, Skip Montanaro wrote:
> 
>     Mongryong> Is there python library for generating unique keys on Linux?
>     Mongryong> Something sort of like Window's HKEY generator.  Thanks.
> 
> Unique over what domain?  For all time?  For just this run?  For just this
> computer?  Int, float, string?
> 
> I'll just toss something simple out there to stimulate your creative juices.
> What about:
> 
>     "%s:%f:%f" % (socket.gethostname(), time.time(), random.random())
> 
> I realize it's not guaranteed to be completely unique, but for most uses it
> will probably be "good enough".  In fact
> 
>     "%s:%f" % (socket.gethostname(), time.time())
> 
> will probably be "good enough" on systems with decent clocks:
> 
>     >>> time.time() == time.time()
>     False
> 
> Skip
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list







More information about the Python-list mailing list