Mercurial > ec-dotfiles
comparison bin/ed2k.py @ 719:bcdf320dabf4 default tip
Rewrite the ed2k again in php
Getting openssl to hash md4 is a pain.
author | nanaya <me@nanaya.net> |
---|---|
date | Sun, 10 Dec 2023 00:35:22 +0900 |
parents | 1f8218896f2a |
children |
comparison
equal
deleted
inserted
replaced
718:1f8218896f2a | 719:bcdf320dabf4 |
---|---|
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) |