Mercurial > ec-dotfiles
annotate bin/ed2k.py @ 692:a04ba615362c
[bashrc] back to prioritizing gnuls for openbsd
It should be fixed by now...? Can't remember what the problem was though.
author | nanaya <me@nanaya.pro> |
---|---|
date | Sun, 23 Oct 2022 01:56:26 +0900 |
parents | 5bafb912837e |
children |
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) |