我正在为Wikipedia的MD5哈希算法实现伪代码。它包括几个称为“ leftrotate”的操作,我指的是“向左移动”。但是,当我实现代码时,一切似乎都可以进行,直到向左移动为止。我不确定这是否是此实现的正确选择,我不确定是怎么做的以获取错误,或者我什至无法正确实现此实现。
# Process the message in successive 512-bit chunks:
binaryArray = [binary[i:i+512] for i in range(0, len(binary), 512)]
for chunk in binaryArray:
M = [int(chunk[i:i+32]) for i in range(0,len(chunk),32)]
A = a0
B = b0
C = c0
D = d0
for i in list(range(0,64)):
if i >= 0 and i <= 15:
F = (B&C)|((~B)&D)
g = i
elif i >= 16 and i <=31:
F = (D&B)|((~D)&C)
g = (5*i+1)%16
elif i >= 32 and i <= 47:
F = (B^C)^D
g = (3*i+5)%16
elif i >= 48 and i <= 63:
F = C^(B|(~D))
g = (7*i)%16
F = F + A + K[i] + M[g]
A = D
D = C
C = B + (F<<s[i]) #This is where the error occurs
a0 = a0 + A
b0 = b0 + B
c0 = c0 + C
d0 = d0 + D
预期:包含明文字符串的MD5哈希的输出文件
获取:错误或输出文件为空