fix when pycrypto not installed

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2009-05-21 14:49:12 -04:00
parent ef3dd28a33
commit 3d9936b8a7
1 changed files with 8 additions and 2 deletions

View File

@ -1,9 +1,15 @@
try:
import Crypto.Hash.SHA256
import Crypto.Cipher.AES
has_aes = True
except:
has_aes = False
class Crypter(object):
ALIGNMENT = 16
def __init__(self, password, salt='aes.py'):
if not has_aes:
raise Exception("pycrypto not installed")
self.password = password
self.salt = salt
self.hash = Crypto.Hash.SHA256.new(password + salt)