diff --git a/oxlib/cache.py b/oxlib/cache.py index b9b8b40..097525a 100644 --- a/oxlib/cache.py +++ b/oxlib/cache.py @@ -2,9 +2,9 @@ # vi:si:et:sw=4:sts=4:ts=4 # GPL 2008 import gzip -import StringIO +import hashlib import os -import sha +import StringIO import time import urlparse import urllib2 @@ -80,9 +80,9 @@ def _getCacheBase(): def _getUrlCacheFile(url, data=None, headers=DEFAULT_HEADERS): if data: - url_hash = sha.sha(url + '?' + data).hexdigest() + url_hash = hashlib.sha1(url + '?' + data).hexdigest() else: - url_hash = sha.sha(url).hexdigest() + url_hash = hashlib.sha1(url).hexdigest() domain = ".".join(urlparse.urlparse(url)[1].split('.')[-2:]) return os.path.join(_getCacheBase(), domain, url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash) diff --git a/oxlib/file.py b/oxlib/file.py index 940b2b7..0d34729 100644 --- a/oxlib/file.py +++ b/oxlib/file.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 # GPL 2008 -import sha import os +import hashlib def sha1sum(filename): - sha1 = sha.new() + sha1 = hashlib.sha1() file=open(filename) buffer=file.read(4096) while buffer: diff --git a/oxlib/torrent.py b/oxlib/torrent.py index c877f07..daf7cb0 100644 --- a/oxlib/torrent.py +++ b/oxlib/torrent.py @@ -3,7 +3,7 @@ # GPL 2007 from threading import Event -import sha +import hashlib from os import stat from BitTornado.BT1.makemetafile import make_meta_file @@ -20,7 +20,7 @@ def getInfoHash(torrentFile): metainfo_file = open(torrentFile, 'rb') metainfo = bdecode(metainfo_file.read()) info = metainfo['info'] - return sha.sha(bencode(info)).hexdigest().upper() + return hashlib.sha1(bencode(info)).hexdigest().upper() def getTorrentInfoFromFile(torrentFile): f = open(torrentFile, 'rb') @@ -51,7 +51,7 @@ def getTorrentInfo(data): if key != 'info': tinfo[key] = metainfo[key] tinfo['size'] = file_length - tinfo['hash'] = sha.sha(bencode(info)).hexdigest() + tinfo['hash'] = hashlib.sha1(bencode(info)).hexdigest() tinfo['announce'] = metainfo['announce'] return tinfo