[pycrypto] AES, python 2.7 vs 3

Dave Pawson dave.pawson at gmail.com
Mon Feb 3 06:56:24 PST 2014


On 3 February 2014 14:51, Mirko Dziadzka <mirko.dziadzka at gmail.com> wrote:
> Hi
>
> Without testing or verifying:
>
> You should probably use bytes in Python 3, not characters.
>
>> v = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
>
> creates a string of 16 (unicode) characters in Python 3
>
> iv = os.urandom(16)
>
> creates 16 bytes
>
>     Mirko

Which is what I had (and works fine in 2.7)

iv = Random.new().read(AES.block_size)
seems to work OK in 3.3


regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk


More information about the pycrypto mailing list