[Tutor] os.urandom()

Richard D. Moores rdmoores at gmail.com
Sat Aug 7 23:04:33 CEST 2010


<http://docs.python.org/py3k/library/os.html?highlight=urandom#os.urandom>

using Vista, Python 3.1:

>>> import os
>>> os.urandom(6)
b'\xd1\xfc\xb0\x14\xeaL'

So what is this output? What in ascii? What in hex?  Do those
questions even make sense?

I've tried 2 things to get at it:
>>> import binascii
>>> binascii.b2a_qp(b'\xd1\xfc\xb0\x14\xeaL')
b'=D1=FC=B0=14=EAL'
>>> binascii.b2a_hex(b'\xd1\xfc\xb0\x14\xeaL')
b'd1fcb014ea4c'

Help, please.

Dick Moores





>>> import binascii
>>> binascii.b2a_qp(b'\x05\x8aU\x92\xf3R')
b'=05=8AU=92=F3R'
>>> binascii.b2a_hex(b'\x05\x8aU\x92\xf3R')
b'058a5592f352'


More information about the Tutor mailing list