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

gert gert.cuykens at gmail.com
Fri Jan 16 01:34:41 CET 2009


On Jan 16, 1:20 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> gert <gert.cuyk... at gmail.com> writes:
> > s = sha1(random()).hexdigest()
>
> > TypeError: object supporting the buffer API required,
>
> > How does sha1 work in python3.0 please ?
>
> sha1 hashes strings, not numbers.  Try using str(random()).  But if
> you want some random hex digits, try os.urandom(10).encode('hex')
> rather than messing with sha1.

 s = urandom(10).encode('hex')

 AttributeError: 'bytes' object has no attribute 'encode'



More information about the Python-list mailing list