Skip to content

Instantly share code, notes, and snippets.

@arcolife
Forked from anonymous/file1.py
Created November 26, 2013 17:26
Show Gist options
  • Save arcolife/7662422 to your computer and use it in GitHub Desktop.
Save arcolife/7662422 to your computer and use it in GitHub Desktop.
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