From 3d9936b8a7955f9645b8557771d8f2cb27fe64bb Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Thu, 21 May 2009 14:49:12 -0400 Subject: [PATCH] fix when pycrypto not installed --HG-- branch : pmacs2 --- aesutil.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aesutil.py b/aesutil.py index 67a3316..fd18ef1 100644 --- a/aesutil.py +++ b/aesutil.py @@ -1,9 +1,15 @@ -import Crypto.Hash.SHA256 -import Crypto.Cipher.AES +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)