summaryrefslogtreecommitdiff
blob: 28bfaa76a90a93204384bf2fbe11df6ad487452f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
DeprecationWarning: the sha module is deprecated; use the hashlib module instead

--- a/BitTorrent/ConvertedMetainfo.py
+++ b/BitTorrent/ConvertedMetainfo.py
@@ -15,7 +15,10 @@ from __future__ import generators
 
 import os
 import sys
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 
 from BitTorrent.obsoletepythonsupport import *
 
--- a/BitTorrent/NewVersion.py
+++ b/BitTorrent/NewVersion.py
@@ -15,7 +15,10 @@ import sys
 import zurllib
 import pickle
 import threading
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 
 DEBUG = False
 
--- a/BitTorrent/PeerID.py
+++ b/BitTorrent/PeerID.py
@@ -11,7 +11,10 @@
 # Written by Matt Chisholm
 
 import os
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from time import time
 try:
     getpid = os.getpid
--- a/BitTorrent/StorageWrapper.py
+++ b/BitTorrent/StorageWrapper.py
@@ -12,7 +12,10 @@
 
 from __future__ import division
 
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from array import array
 from binascii import b2a_hex
 
--- a/BitTorrent/download.py
+++ b/BitTorrent/download.py
@@ -19,7 +19,10 @@ import sys
 import threading
 import errno
 import gc
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from socket import error as socketerror
 from random import seed
 from time import time
--- a/BitTorrent/makemetafile.py
+++ b/BitTorrent/makemetafile.py
@@ -16,7 +16,10 @@ from __future__ import division
 
 import os
 import sys
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from time import time
 from threading import Event
 
--- a/BitTorrent/parsedir.py
+++ b/BitTorrent/parsedir.py
@@ -11,7 +11,10 @@
 # Written by John Hoffman and Uoti Urpala
 
 import os
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 
 from BitTorrent.bencode import bencode, bdecode
 from BitTorrent.btformats import check_message
--- a/khashmir/khash.py
+++ b/khashmir/khash.py
@@ -8,7 +8,10 @@
 # for the specific language governing rights and limitations under the
 # License.
 
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from random import randint
 
 #this is ugly, hopefully os.entropy will be in 2.4
--- a/khashmir/khashmir.py
+++ b/khashmir/khashmir.py
@@ -13,7 +13,10 @@ from socket import gethostbyname
 
 from BitTorrent.platform import bttime as time
 
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 import re
 from BitTorrent.defaultargs import common_options, rare_options
 from BitTorrent.RawServer_magic import RawServer
--- a/khashmir/utkhashmir.py
+++ b/khashmir/utkhashmir.py
@@ -13,7 +13,10 @@ from actions import *
 from khash import newID
 from krpc import KRPCProtocolError, KRPCFailSilently
 from cache import Cache
-from sha import sha
+try:
+    from hashlib import sha1 as sha
+except ImportError:
+    from sha import sha
 from util import *
 from threading import Thread
 from socket import gethostbyname