Skip to content

Instantly share code, notes, and snippets.

@blindFS
Created July 23, 2014 08:07
Show Gist options
  • Save blindFS/824c035e57269bd98b0a to your computer and use it in GitHub Desktop.
Save blindFS/824c035e57269bd98b0a to your computer and use it in GitHub Desktop.
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