use hashlib instead of sha

This commit is contained in:
j 2009-03-16 18:15:14 +01:00
parent d0d5ee8132
commit 3c6e12f3a9
3 changed files with 9 additions and 9 deletions

View file

@ -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)

View file

@ -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:

View file

@ -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