mervick / aes-everywhere

Aes Everywhere - Cross Language AES 256 Encryption Library (Bash, Powershell, C#, Dart, GoLang, Java, JavaScript, Lua, PHP, Python, Ruby, Swift)
Other
474 stars 169 forks source link

Issue with copyright symbols #13

Closed johnjjung closed 4 years ago

johnjjung commented 5 years ago

This is python3.5

I'm sure I have # -*- coding: utf-8 -*- at the top of the file, but not sure what's going on.

if __name__ == '__main__':    #code to execute if called from command-line
    test = '''©'''
    print(aes256().decrypt(aes256().encrypt(test, "pass"), "pass"))

self.__pkcs5_padding(raw) outputs

raw_padded b'\xc2\xa9\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f'

Then throws an error at

cipher_encrypted = cipher.encrypt(raw_padded)
  File "/usr/local/lib/python3.5/site-packages/Crypto/Cipher/blockalgo.py", line 244, in encrypt
    return self._cipher.encrypt(plaintext)
ValueError: Input strings must be a multiple of 16 in length
johnjjung commented 5 years ago

Well it looks like if we do something like this, then it'll strip out unsafe characters

if __name__ == '__main__':    #code to execute if called from command-line
    test = '''©'''
    test = test.encode('ascii','ignore').decode('utf-8')
    print(aes256().decrypt(aes256().encrypt(test, "pass"), "pass"))
johnjjung commented 5 years ago

Issues with passing None

if __name__ == '__main__':    #code to execute if called from command-line
    test = None
    print(aes256().decrypt(aes256().encrypt(test, "pass"), "pass"))

Throws error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/base64.py", line 81, in b64decode
    s = _bytes_from_decode_data(s)
  File "/usr/local/lib/python3.5/base64.py", line 46, in _bytes_from_decode_data
    "string, not %r" % s.__class__.__name__) from None
TypeError: argument should be a bytes-like object or ASCII string, not 'NoneType'
johnjjung commented 5 years ago

Same thing with emojis

if __name__ == '__main__':    #code to execute if called from command-line
    test = '''🌷'''
    test = test.encode('ascii','ignore').decode('utf-8')
    print(aes256().decrypt(aes256().encrypt(test, "pass"), "pass"))

Just doubled checked and emoji's can be encrypted decrypted using aes256cbc

Screen Shot 2019-04-15 at 8 27 22 PM