SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Hashing Summary MD5 is a function used in cryptography to ensure data integrity. The idea of hashing is to create a unique code for a set of data through the use of functions. It was created by Ronald Rivest in 1991 and each message digest is 128 bits long. You can find more details in RFC There are two main steps in generating an MD5 digest. Pre-processing of data, and hash generation.
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Data Preprocessing Preprocessing: First we need two unsigned integer arrays with 64 items in each. Lets use 'r' for the rotational array and 'k' for the constant array r[ 0..15] := {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22} r[16..31] := {5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20} r[32..47] := {4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23} r[48..63] := {6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21} Use the following formula to generate the constants: for i from 0 to 63 k[i] := floor(abs(sin(i + 1)) × (2 pow 32)) We also need 4 constant variables to start bit shifting (these are arbitrary but need to be the same in all MD5 generators) var int h0 := 0x var int h1 := 0xEFCDAB89 var int h2 := 0x98BADCFE var int h3 := 0x Pre-processing the data is as follows: 1) Convert the data to a byte array 2) Append '1' bit to the data 3) Append '0' bits until message length in bits is 64 bits short of being a perfect multiple of 512 4) Append bit length of unpadded message as 64-bit little-endian integer to message The pre-processing of the data is done. Now we just run the data through the functions.
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Pseudo code For each 512-bit chunk of message break chunk into sixteen 32-bit little-endian words w[i] for(i=0;i<15;i++) /* Initialize hash value for this chunk: (recall h0,h1,h2,h3 were declared as constants earlier) */ var int a := h0 var int b := h1 var int c := h2 var int d := h3 /* Main loop: */ /* Here are the logic functions that define this algorithm */ for i from 0 to 63 if 0 ≤ i ≤ 15 then f := (b and c) or ((not b) and d) g := i else if 16 ≤ i ≤ 31 f := (d and b) or ((not d) and c) g := (5×i + 1) mod 16 else if 32 ≤ i ≤ 47 f := b xor c xor d g := (3×i + 5) mod 16 else if 48 ≤ i ≤ 63 f := c xor (b or (not d)) g := (7×i) mod 16 temp := d d := c c := b b := b + leftrotate((a + f + k[i] + w[g]), r[i]) a := temp h0 := h0 + a h1 := h1 + b h2 := h2 + c h3 := h3 + d After all rounds are complete, the message digest is h0 append h1 append h2 append h3
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation From User Input User Input String: 'sfgsdfgdfgd' User Input Bytes:
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation From User Input After Pre-Processing of data, Message Bytes: There will be 1 iteration(s) since the padded message size is 512 bits long
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Now we continue to crank through the 4 logic functions provided in the RFC Before we start the process the constant variables are as follows: h0: h1: h2: h3:
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 1 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (7) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 2 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (12) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 3 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (17) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 4 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (22) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 5 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (7) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 6 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (12) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 7 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (17) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 8 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (22) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 9 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (7) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 10 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (12) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 11 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (17) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 12 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (22) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 13 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (7) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 14 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (12) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 15 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (88) R Constant: (17) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 16 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (22) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 17 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (5) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 18 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (9) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 19 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (14) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 20 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (20) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 21 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (5) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 22 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (9) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 23 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (14) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 24 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (20) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 25 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (5) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 26 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (88) R Constant: (9) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 27 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (14) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 28 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (20) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 29 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (5) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 30 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (9) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 31 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (14) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 32 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (20) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 33 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (4) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 34 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (11) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 35 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (16) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 36 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (88) R Constant: (23) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 37 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (4) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 38 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (11) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 39 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (16) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 40 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (23) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 41 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (4) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 42 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (11) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 43 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (16) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 44 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (23) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 45 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (4) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 46 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (11) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 47 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (16) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 48 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (23) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 49 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (6) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 50 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (10) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 51 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (88) R Constant: (15) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 52 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (21) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 53 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (6) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 54 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (10) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 55 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (15) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 56 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (21) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 57 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (6) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 58 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (10) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 59 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (15) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 60 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (21) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 61 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (6) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 62 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (10) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 63 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: ( ) R Constant: (15) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Iteration 1: Step 64 a = d, d = c, c = b, b = previous resulting value a: ( ) b: ( ) c: ( ) d: ( ) Data Block: (0) R Constant: (21) Sin Value: ( ) Logic Function: ( )int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant) Result after shifting: ( )
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation After Iteration 1: Add the new result to the previous iteration's result h0 + A: h1 + B: h2 + C: h3 + D:
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation After all iterations are complete h0: (Hex: 879f7463) h1: (Hex: f ) h2: (Hex: b8d11efb) h3: (Hex: 2a3ce3e6) The final digest: 879f7463f b8d11efb2a3ce3e6
SUNY Oneonta Data Structures and Algorithms Visualization Group MD5 Generation Summary As you can see, there is quite a bit of bit shifting happening which makes it nearly impossible to reverse engineer The goal of generating hash keys (i.e. Message Digests) is exactly this- to ensure data integrity. Hopefully this presentation has helped you gain a better understanding of how the process of key generation works.
SUNY Oneonta Data Structures and Algorithms Visualization Group