diff bin/ed2k.py @ 124:5bafb912837e

Massive addition of old scripts collection.
author Edho Prima Arief <edho@myconan.net>
date Wed, 26 Oct 2011 15:22:00 +0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ed2k.py	Wed Oct 26 15:22:00 2011 +0700
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+import os, sys
+from Crypto.Hash import MD4
+
+def ed2k(filename):
+  block = 9500*1024
+  hash = ""
+  file = open(filename, "rb")
+  fileblock = file.read(block)
+  while fileblock:
+    hash += MD4.new(fileblock).digest()
+    fileblock = file.read(block)
+  file.close()
+  return MD4.new(hash).hexdigest()
+
+if __name__ == "__main__":
+  for file in sys.argv[1:]:
+    print "%s %s" %(ed2k(file), file)