s = sha1(random()).hexdigest()

James Mills prologic at shortcircuit.net.au
Fri Jan 16 00:04:33 EST 2009


On Fri, Jan 16, 2009 at 2:46 PM, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> gert <gert.cuykens at gmail.com> writes:
>>  s = urandom(10).encode('hex')
>>  AttributeError: 'bytes' object has no attribute 'encode'
>
> Oh, Python 3.  It's done some different way, someone else will have to
> specify.  I'm still using 2.x.

>>> "".join([hex(c) for c in os.urandom(10)])
'0x540x6c0xdf0xd90xe10x7c0x330x370x9a0x8'
>>>



More information about the Python-list mailing list