MD5/Implementation: Difference between revisions

Content added Content deleted
Line 47: Line 47:
functions [+]= (b, c, d) -> c (+) (b [|] (-)d)
functions [+]= (b, c, d) -> c (+) (b [|] (-)d)


[(UInt32 -> UInt32)] index_functions
[(Int -> Int)] index_functions
index_functions [+]= i -> i
index_functions [+]= i -> i
index_functions [+]= i -> (5 * i + 1) % 16
index_functions [+]= i -> (5 * i + 1) % 16
Line 68: Line 68:
V f = :functions[i I/ 16](b, c, d)
V f = :functions[i I/ 16](b, c, d)
V g = :index_functions[i I/ 16](i)
V g = :index_functions[i I/ 16](i)
V to_rotate = a + f + :constants[i] + UInt32(bytes' chunk[4 * Int(g) .+ 4])
V to_rotate = a + f + :constants[i] + UInt32(bytes' chunk[4 * g .+ 4])
V new_b = UInt32(b + rotl(to_rotate, :rotate_amounts[i]))
V new_b = UInt32(b + rotl(to_rotate, :rotate_amounts[i]))
(a, b, c, d) = (d, new_b, b, c)
(a, b, c, d) = (d, new_b, b, c)