@@ -107,7 +107,7 @@ def Mill(a,wl):
107
107
return A
108
108
109
109
class RadioGatunType :
110
- "An implementation of the MD5 hash function in pure Python."
110
+ "An implementation of the RadioGatun hash function in pure Python."
111
111
112
112
def __init__ (self ,wl ):
113
113
"""Initialisation.
@@ -125,7 +125,7 @@ def __init__(self,wl):
125
125
126
126
# Initial message length in bits(!).
127
127
self .length = 0L
128
- self .count = [ 0 , 0 ]
128
+ self .count = 0
129
129
130
130
# Initial empty message as a sequence of bytes (8 bit characters).
131
131
self .input = ""
@@ -137,12 +137,14 @@ def __init__(self,wl):
137
137
138
138
def init (self ):
139
139
"""Initialize the message-digest and set all fields to zero.
140
+
141
+ Can be used to reinitialize the hash object
140
142
"""
141
143
142
144
self .S = stateInit ()
143
145
144
146
self .length = 0L
145
- self .count = [ 0 , 0 ]
147
+ self .count = 0
146
148
self .input = ""
147
149
148
150
def _transform (self , inp ):
@@ -179,10 +181,10 @@ def update(self, inBuf):
179
181
leninBuf = long (len (inBuf ))
180
182
181
183
# Compute number of bytes mod 64.
182
- index = (self .count [ 0 ] >> 3 ) % self .blocklength
184
+ index = (self .count >> 3 ) % self .blocklength
183
185
184
186
# Update number of bits.
185
- self .count [ 0 ] = self .count [ 0 ] + (leninBuf << 3 )
187
+ self .count = self .count + (leninBuf << 3 )
186
188
187
189
partLen = self .blocklength - index
188
190
@@ -220,14 +222,14 @@ def digest(self, length=256):
220
222
221
223
S = self .S
222
224
inp = "" + self .input
223
- count = [] + self .count
225
+ count = self .count
224
226
225
- index = (self .count [ 0 ] >> 3 ) % self .blocklength
227
+ index = (self .count >> 3 ) % self .blocklength
226
228
227
229
if index < self .blocklength :
228
230
padLen = self .blocklength - index
229
231
else :
230
- padLen = 2 * self .blocklength - index
232
+ padLen = 2 * self .blocklength - index
231
233
232
234
#provide padding chars encoded as little endian
233
235
padding = ['\001 ' ] + ['\000 ' ] * (padLen - 1 )
0 commit comments