fix encrypt_all
This commit is contained in:
parent
cbf8c6705b
commit
039451bcfb
1 changed files with 5 additions and 2 deletions
|
@ -77,7 +77,7 @@ def EVP_BytesToKey(password, key_len, iv_len):
|
||||||
key = ms[:key_len]
|
key = ms[:key_len]
|
||||||
iv = ms[key_len:key_len + iv_len]
|
iv = ms[key_len:key_len + iv_len]
|
||||||
cached_keys[password] = (key, iv)
|
cached_keys[password] = (key, iv)
|
||||||
return (key, iv)
|
return key, iv
|
||||||
|
|
||||||
|
|
||||||
class Encryptor(object):
|
class Encryptor(object):
|
||||||
|
@ -148,7 +148,10 @@ def encrypt_all(password, method, op, data):
|
||||||
result = []
|
result = []
|
||||||
method = method.lower()
|
method = method.lower()
|
||||||
(key_len, iv_len, m) = method_supported[method]
|
(key_len, iv_len, m) = method_supported[method]
|
||||||
(key, _) = EVP_BytesToKey(password, key_len, iv_len)
|
if key_len > 0:
|
||||||
|
key, _ = EVP_BytesToKey(password, key_len, iv_len)
|
||||||
|
else:
|
||||||
|
key = password
|
||||||
if op:
|
if op:
|
||||||
iv = random_string(iv_len)
|
iv = random_string(iv_len)
|
||||||
result.append(iv)
|
result.append(iv)
|
||||||
|
|
Loading…
Add table
Reference in a new issue