-
-
Save arcolife/7662422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Cipher import AES,DES,Blowfish,CAST, XOR | |
from Crypto.Hash import MD5,SHA256,hashalgo, SHA,SHA512 | |
import base64 | |
import os | |
def encryption(privateInfo): | |
BLOCK_SIZE = 16 | |
PADDING = '{' | |
def encryption(privateInfo): | |
BLOCK_SIZE = 16 | |
PADDING = '{' | |
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE ) * PADDING | |
def encryption(privateInfo): | |
BLOCK_SIZE = 16 | |
PADDING = '{' | |
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE ) * PADDING | |
EncodeAES = lambda c, s:base64.b64encode(c.encrypt(pad(s))) | |
secret = os.urandom(BLOCK_SIZE) | |
print 'encryption key: ',secret | |
cipher = AES.new(secret) | |
encoded = EncodeAES(cipher, privateInfo) | |
print 'Encrypted string: ',encoded | |
encryption('blabla fuck ass shit') | |
%logstart aes.py | |
cat aes.py | |
def decryption(encryptedString): | |
PADDING = '{' | |
DecodeAES = lambda c,e: c.decrypt(base64.b64decode(e)).rstrip(PADDING) | |
key = raw_input() | |
cipher = AES.new(key) | |
decoded = DecodeAES(cipher, encryptedString) | |
print "Decoded String: ", decoded | |
%logstart aes.py | |
%logstart des.py | |
%logstart des.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment