python-oxlib/oxlib/hashes.py

18 lines
323 B
Python
Raw Normal View History

2008-04-27 16:54:37 +00:00
# -*- coding: utf-8 -*-
2008-06-19 09:21:21 +00:00
# vi:si:et:sw=4:sts=4:ts=4
2008-04-27 16:54:37 +00:00
# GPL written 2008 by j@pad.ma
import sha
import os
def sha1sum(filename):
2008-06-19 09:21:21 +00:00
sha1 = sha.new()
file=open(filename)
2008-04-27 16:54:37 +00:00
buffer=file.read(4096)
2008-06-19 09:21:21 +00:00
while buffer:
sha1.update(buffer)
buffer=file.read(4096)
file.close()
return sha1.hexdigest()
2008-04-27 16:54:37 +00:00