Skip to content

Instantly share code, notes, and snippets.

@spalladino
Created October 21, 2017 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spalladino/5badbe88025d3d60c8470661c140ea5d to your computer and use it in GitHub Desktop.
Save spalladino/5badbe88025d3d60c8470661c140ea5d to your computer and use it in GitHub Desktop.
Solution for Coursera Cryptography 1 course Week 3 programming assignment
from hashlib import sha256
from sys import argv
with open(argv[1], "rb") as f:
blocks = []
block = f.read(1024)
while block:
blocks.append(block)
block = f.read(1024)
h = sha256(blocks[-1])
for block in reversed(blocks[:-1]):
h = sha256(block + h.digest())
print(h.hexdigest())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment