comparison bin/ed2k.py @ 129:f18a27a0e8fc

Merge branch.
author Edho Arief <edho@myconan.net>
date Sat, 29 Oct 2011 11:40:35 +0700
parents 5bafb912837e
children
comparison
equal deleted inserted replaced
121:0c3b473b9af7 129:f18a27a0e8fc
1 #!/usr/bin/env python
2
3 import os, sys
4 from Crypto.Hash import MD4
5
6 def ed2k(filename):
7 block = 9500*1024
8 hash = ""
9 file = open(filename, "rb")
10 fileblock = file.read(block)
11 while fileblock:
12 hash += MD4.new(fileblock).digest()
13 fileblock = file.read(block)
14 file.close()
15 return MD4.new(hash).hexdigest()
16
17 if __name__ == "__main__":
18 for file in sys.argv[1:]:
19 print "%s %s" %(ed2k(file), file)