Created
July 23, 2014 08:07
-
-
Save blindFS/824c035e57269bd98b0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Hash import SHA256 | |
import os | |
def myhash(): | |
file = open('./test.mp4', 'rb') | |
size = os.path.getsize('./test.mp4') | |
block_num = size/1024 | |
file.seek(block_num*1024) | |
bs = file.read() | |
ha = SHA256.new() | |
ha.update(bs) | |
hlast = ha.digest() | |
while block_num > 0: | |
file.seek((block_num-1)*1024) | |
bs = file.read(1024) | |
ha = SHA256.new() | |
ha.update(bs+hlast) | |
hlast = ha.digest() | |
block_num -= 1 | |
print hlast.encode('hex') | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment