lbry-sdk/lbrynet/cryptstream/client/CryptBlobHandler.py
Job Evers-Meltzer b64fa51567 fixup long lines
2016-12-07 09:38:34 -05:00

20 lines
602 B
Python

import binascii
from zope.interface import implements
from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor
from lbrynet.interfaces import IBlobHandler
class CryptBlobHandler(object):
implements(IBlobHandler)
def __init__(self, key, write_func):
self.key = key
self.write_func = write_func
######## IBlobHandler #########
def handle_blob(self, blob, blob_info):
blob_decryptor = StreamBlobDecryptor(
blob, self.key, binascii.unhexlify(blob_info.iv), blob_info.length)
d = blob_decryptor.decrypt(self.write_func)
return d