more robust

This commit is contained in:
clowwindy 2013-05-23 12:10:31 +08:00
parent 44aa5387c2
commit 8b2f26c08e
2 changed files with 13 additions and 3 deletions

View file

@ -60,7 +60,11 @@ def init_table(key, method=None):
encrypt_table = ''.join(get_table(key))
decrypt_table = string.maketrans(encrypt_table, string.maketrans('', ''))
else:
Encryptor(key, method) # make an Encryptor to test if the settings if OK
try:
Encryptor(key, method) # make an Encryptor to test if the settings if OK
except Exception as e:
logging.error(e)
sys.exit(1)
def EVP_BytesToKey(password, key_len, iv_len):
@ -88,9 +92,15 @@ method_supported = {
'aes-192-cfb': (24, 16),
'aes-256-cfb': (32, 16),
'bf-cfb': (16, 8),
'camellia-128-cfb': (16, 16),
'camellia-192-cfb': (24, 16),
'camellia-256-cfb': (32, 16),
'cast5-cfb': (16, 8),
'des-cfb': (8, 8),
'idea-cfb': (16, 8),
'rc2-cfb': (8, 8),
'rc4': (16, 0),
'seed-cfb': (16, 16),
}

View file

@ -179,11 +179,11 @@ if __name__ == '__main__':
elif key == '-m':
METHOD = value
encrypt.init_table(KEY, METHOD)
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
encrypt.init_table(KEY, METHOD)
try:
server = ThreadingTCPServer(('', PORT), Socks5Server)
logging.info("starting server at port %d ..." % PORT)