merged lbrynet/cryptstream into lbrynet/blob
This commit is contained in:
parent
1292eb345d
commit
0d4e83e167
6 changed files with 0 additions and 8 deletions
lbrynet/blob/client
22
lbrynet/blob/client/CryptBlobHandler.py
Normal file
22
lbrynet/blob/client/CryptBlobHandler.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import binascii
|
||||
from twisted.internet import defer
|
||||
from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor
|
||||
|
||||
|
||||
class CryptBlobHandler:
|
||||
#implements(IBlobHandler)
|
||||
|
||||
def __init__(self, key, write_func):
|
||||
self.key = key
|
||||
self.write_func = write_func
|
||||
|
||||
######## IBlobHandler #########
|
||||
|
||||
def handle_blob(self, blob, blob_info):
|
||||
try:
|
||||
blob_decryptor = StreamBlobDecryptor(blob, self.key, binascii.unhexlify(blob_info.iv),
|
||||
blob_info.length)
|
||||
except ValueError as err:
|
||||
return defer.fail(err)
|
||||
d = blob_decryptor.decrypt(self.write_func)
|
||||
return d
|
Loading…
Add table
Add a link
Reference in a new issue