Multi threaded eciesDecrypt
This commit is contained in:
parent
c52d47b15f
commit
7b210429b5
6 changed files with 89 additions and 11 deletions
|
@ -2,6 +2,7 @@ import hashlib
|
|||
import base64
|
||||
|
||||
import lib.pybitcointools as btctools
|
||||
from Crypt import Crypt
|
||||
|
||||
ecc_cache = {}
|
||||
|
||||
|
@ -22,10 +23,24 @@ def eciesEncrypt(data, pubkey, ephemcurve=None, ciphername='aes-256-cbc'):
|
|||
mac = pyelliptic.hmac_sha256(key_m, ciphertext)
|
||||
return key_e, ciphertext + mac
|
||||
|
||||
|
||||
@Crypt.thread_pool_crypt.wrap
|
||||
def eciesDecryptMulti(encrypted_datas, privatekey):
|
||||
texts = [] # Decoded texts
|
||||
for encrypted_data in encrypted_datas:
|
||||
try:
|
||||
text = eciesDecrypt(encrypted_data, privatekey).decode("utf8")
|
||||
texts.append(text)
|
||||
except:
|
||||
texts.append(None)
|
||||
return texts
|
||||
|
||||
|
||||
def eciesDecrypt(encrypted_data, privatekey):
|
||||
ecc_key = getEcc(privatekey)
|
||||
return ecc_key.decrypt(base64.b64decode(encrypted_data))
|
||||
|
||||
|
||||
def split(encrypted):
|
||||
iv = encrypted[0:16]
|
||||
ciphertext = encrypted[16 + 70:-32]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue