I was playing around PyCrypto's AES and DES implementation. Every time, I decrypted a cipher text, that I encrypted from a plain text, It gives out random strings.
I have tried the following:
from Crypto.Cipher import AES,DES
from Crypto import Random
iv_AES = Random.new().read(AES.block_size)
iv_DES = Random.get_random_bytes(8)
key_AES = 'abcdefghijklmnop'
key_DES = 'abcdefgh'
aes = AES.new(key_AES,AES.MODE_CFB,iv_AES)
aes1 = AES.new(key_AES,AES.MODE_CFB,iv_AES)
des = DES.new(key_DES,DES.MODE_CFB,iv_DES)
des1 = DES.new(key_DES,DES.MODE_CFB,iv_DES)
plaintext = 'Hello! World'
print plaintext == aes.decrypt(aes.encrypt(plaintext))
print plaintext == des.decrypt(des.encrypt(plaintext))
print plaintext == aes1.decrypt(aes.encrypt(plaintext))
print plaintext == des1.decrypt(des.encrypt(plaintext))
Result:
False
False
True
True
I don't understand why this is happening.
Can you please explain what is actually happening here, and why is it so?