Add files via upload

This commit is contained in:
Kaushal Kumar Agarwal 2018-06-20 23:17:10 +05:30 committed by GitHub
parent c7e1764fce
commit 70d2494a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

34
Aes256.py Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python3
import os
from Crypto.Cipher import AES
key=os.urandom(32)
print("Key Generated")
print(key)
IV = 16*'\x00'
mode = AES.MODE_CBC
encryptor=AES.new(key,mode,IV=IV)
decryptor=AES.new(key,mode,IV=IV)
def encrypt(msg):
n=len(msg)
if n==0:
return
elif n%16!=0:
msg+=' '*(16-(n%16))
cipher=encryptor.encrypt(msg)
print("Encrypted Text")
print(cipher)
print("Checking for decryption")
text=decryptor.decrypt(cipher);
length=len(text)
if(length>n):
plain_text=text[:n]
else:
plain_text=text
print("Decrypted Text")
print(plain_text)
msg=input('Enter The Message To Be Encrypted\n')
encrypt(msg)