Skip to content

Instantly share code, notes, and snippets.

@meejah
Created June 5, 2017 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meejah/6bae3497cf0f71d87060e10e26ae7737 to your computer and use it in GitHub Desktop.
Save meejah/6bae3497cf0f71d87060e10e26ae7737 to your computer and use it in GitHub Desktop.
class _HashSumProtocol(Protocol):
def __init__(self, kind='sha256'):
self._hash = hashlib.new(kind)
def dataReceived(self, data):
self.bytes_received += len(data)
self._hash.update(data)
@meejah
Copy link
Author

meejah commented Jun 5, 2017

then you'd do something like this with a twisted.web.client Agent:

        resp = yield agent.request('GET', uri)
        hasher = _HashSumProtocol()
        resp.deliverBody(hasher)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment