From 70d2494a9fa1cc3d7adf899620c68b97dd1e8d91 Mon Sep 17 00:00:00 2001 From: Kaushal Kumar Agarwal Date: Wed, 20 Jun 2018 23:17:10 +0530 Subject: [PATCH] Add files via upload --- Aes256.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Aes256.py diff --git a/Aes256.py b/Aes256.py new file mode 100644 index 0000000..f0b6510 --- /dev/null +++ b/Aes256.py @@ -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) \ No newline at end of file