annotate bin/ed2k.py @ 341:675590e84904

[rc/cshrc] Better LSCOLORS, prompt.
author Edho Arief <edho@myconan.net>
date Sun, 25 Mar 2012 16:42:46 +0700
parents 5bafb912837e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
1 #!/usr/bin/env python
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
2
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
3 import os, sys
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
4 from Crypto.Hash import MD4
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
5
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
6 def ed2k(filename):
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
7 block = 9500*1024
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
8 hash = ""
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
9 file = open(filename, "rb")
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
10 fileblock = file.read(block)
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
11 while fileblock:
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
12 hash += MD4.new(fileblock).digest()
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
13 fileblock = file.read(block)
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
14 file.close()
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
15 return MD4.new(hash).hexdigest()
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
16
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
17 if __name__ == "__main__":
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
18 for file in sys.argv[1:]:
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
19 print "%s %s" %(ed2k(file), file)