I am in the process of implementing Wikipedia's pseudocode for the MD5 hashing algorithm. It includes several operations called "leftrotate," which I took to mean "shift left." However, when I implement the code, everything appears to work up until the left shifts. I'm not certain that this is the correct choice for this implementation, and what I am doing wrong to get the errors, or if I'm even approaching this implementation correctly.
# 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
Expected: An output file containing the MD5 hash of a plaintext string
Getting: Errors or an empty output file