Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (16 sloc) 584 Bytes
from Crypto.Cipher import AES
import base64
import os
class Crypt(object):
def __init__(self, secret=os.urandom(BLOCKSIZE)):
if len(secret) != self.BLOCKSIZE:
raise Exception("Secret should be %s long, was %s" % \
(self.BLOCKSIZE, len(secret)))
self.secret = secret
def prepare(self, data):
encrypter =, AES.MODE_CFB)
return base64.b64encode(encrypter.encrypt(data))
def unprepare(self, data):
decrypter =, AES.MODE_CFB)
return decrypter.decrypt(base64.b64decode(data))
Something went wrong with that request. Please try again.