Should reject Unicode strings in Python 3.x

Bug #1084873 reported by Craig McQueen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python-Crypto
Confirmed
High
Unassigned

Bug Description

The docs in PyPI give an example:

>>> from Crypto.Cipher import AES
>>> obj = AES.new('This is a key456', AES.MODE_ECB)
>>> message = "The answer is no"
>>> ciphertext = obj.encrypt(message)
>>> ciphertext
'o\x1aq_{P+\xd0\x07\xce\x89\xd1=M\x989'

In Python 3.x, the encrypt function shouldn't accept the Unicode string input. It should only accept a byte string input. I.e. it should only work if we change the third line to:

>>> message = b"The answer is no"

Revision history for this message
Darsey Litzenberger (dlitz) wrote :

Agreed. PyCrypto should behave like a Python 3 user would expect when running under Python 3.

Changed in pycrypto:
status: New → Confirmed
Revision history for this message
Craig McQueen (cmcqueen1975) wrote :

It should only accept a byte string, not Unicode, for the encryption key as well --

    obj = AES.new(b'This is a key456', AES.MODE_ECB)

Changed in pycrypto:
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.