/hack/blockfs/cfs/encrwfs.py
https://bitbucket.org/arigo/arigo/ · Python · 18 lines · 13 code · 5 blank · 0 comment · 0 complexity · 53510fd1c194ae79d4fe6d9ab8442605 MD5 · raw file
- import md5
- from Crypto.Cipher import Blowfish
- from blockrwfs import BlockRWFS
- class EncryptedBlockRWFS(BlockRWFS):
- SECRETKEYSIZE = md5.digest_size
- def set_secret_key(self, secretkey):
- self.secretkey = secretkey
- def encrypt(self, data, salt=''):
- return Blowfish.new(self.secretkey,
- Blowfish.MODE_CBC, salt[:8]).encrypt(data)
- def decrypt(self, data, salt=''):
- return Blowfish.new(self.secretkey,
- Blowfish.MODE_CBC, salt[:8]).decrypt(data)