view bin/ed2k.py @ 684:6010e722b5da

[irbrc] Disable syntax highlighting as it slows down things Reference: https://github.com/ruby/irb/issues/292
author nanaya <me@nanaya.pro>
date Wed, 14 Sep 2022 19:06:13 +0900
parents 5bafb912837e
children
line wrap: on
line source

#!/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)