75
MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen

MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen

  • View
    277

  • Download
    3

Embed Size (px)

Citation preview

MD5 Generation

Auto-Generated Slides To Visualize MD5 Hash Generation by Chris

Fremgen

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 1321.

There are two main steps in generating an MD5 digest. Pre-processing of data, and hash generation.

MD5 Data PreprocessingPreprocessing: 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 := 0x67452301 var int h1 := 0xEFCDAB89 var int h2 := 0x98BADCFE var int h3 := 0x10325476

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.

MD5 Pseudo codeFor 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

MD5 Generation From User Input

User Input String: 'hello'User Input Bytes: 104 101 108 108 111

MD5 Generation From User InputAfter Pre-Processing of data, Message Bytes: 104 101

108 108 111 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0

There will be 1 iteration(s) since the padded message size is 512 bits long

MD5 GenerationNow 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: 1732584193h1: 4023233417h2: 2562383102h3: 271733878

MD5 Generation Iteration 1: Step 1a = d, d = c, c = b, b = previous resulting value

a: (1732584193)01100111010001010010001100000001b: (4023233417)11101111110011011010101110001001c: (2562383102)10011000101110101101110011111110d: (271733878)00010000001100100101010001110110

Data Block: (1819043176)01101100011011000110010101101000R Constant: (7)00000000000000000000000000000111Sin Value: (3614090360)11010111011010101010010001111000

Logic Function: (1732584193)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3679623978)11011011010100101001101100101010

MD5 Generation Iteration 1: Step 2a = d, d = c, c = b, b = previous resulting value

a: (271733878)00010000001100100101010001110110b: (3679623978)11011011010100101001101100101010c: (4023233417)11101111110011011010101110001001d: (2562383102)10011000101110101101110011111110

Data Block: (32879)00000000000000001000000001101111R Constant: (12)00000000000000000000000000001100Sin Value: (3905402710)11101000110001111011011101010110

Logic Function: (271733878)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (286529400)00010001000101000001011101111000

MD5 Generation Iteration 1: Step 3a = d, d = c, c = b, b = previous resulting value

a: (2562383102)10011000101110101101110011111110b: (286529400)00010001000101000001011101111000c: (3679623978)11011011010100101001101100101010d: (4023233417)11101111110011011010101110001001

Data Block: (0)00000000000000000000000000000000R Constant: (17)00000000000000000000000000010001Sin Value: (606105819)00100100001000000111000011011011

Logic Function: (2562383102)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (605655266)00100100000110011001000011100010

MD5 Generation Iteration 1: Step 4a = d, d = c, c = b, b = previous resulting value

a: (4023233417)11101111110011011010101110001001b: (605655266)00100100000110011001000011100010c: (286529400)00010001000101000001011101111000d: (3679623978)11011011010100101001101100101010

Data Block: (0)00000000000000000000000000000000R Constant: (22)00000000000000000000000000010110Sin Value: (3250441966)11000001101111011100111011101110

Logic Function: (4023233417)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2617034823)10011011111111001100100001000111

MD5 Generation Iteration 1: Step 5a = d, d = c, c = b, b = previous resulting value

a: (3679623978)11011011010100101001101100101010b: (2617034823)10011011111111001100100001000111c: (605655266)00100100000110011001000011100010d: (286529400)00010001000101000001011101111000

Data Block: (0)00000000000000000000000000000000R Constant: (7)00000000000000000000000000000111Sin Value: (4118548399)11110101011111000000111110101111

Logic Function: (3679623978)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (262009391)00001111100111011111001000101111

MD5 Generation Iteration 1: Step 6a = d, d = c, c = b, b = previous resulting value

a: (286529400)00010001000101000001011101111000b: (262009391)00001111100111011111001000101111c: (2617034823)10011011111111001100100001000111d: (605655266)00100100000110011001000011100010

Data Block: (0)00000000000000000000000000000000R Constant: (12)00000000000000000000000000001100Sin Value: (1200080426)01000111100001111100011000101010

Logic Function: (286529400)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2575600242)10011001100001001000101001110010

MD5 Generation Iteration 1: Step 7a = d, d = c, c = b, b = previous resulting value

a: (605655266)00100100000110011001000011100010b: (2575600242)10011001100001001000101001110010c: (262009391)00001111100111011111001000101111d: (2617034823)10011011111111001100100001000111

Data Block: (0)00000000000000000000000000000000R Constant: (17)00000000000000000000000000010001Sin Value: (2821735955)10101000001100000100011000010011

Logic Function: (605655266)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3418241791)11001011101111100011101011111111

MD5 Generation Iteration 1: Step 8a = d, d = c, c = b, b = previous resulting value

a: (2617034823)10011011111111001100100001000111b: (3418241791)11001011101111100011101011111111c: (2575600242)10011001100001001000101001110010d: (262009391)00001111100111011111001000101111

Data Block: (0)00000000000000000000000000000000R Constant: (22)00000000000000000000000000010110Sin Value: (4249261313)11111101010001101001010100000001

Logic Function: (2617034823)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3125275976)10111010010001111110110101001000

MD5 Generation Iteration 1: Step 9a = d, d = c, c = b, b = previous resulting value

a: (262009391)00001111100111011111001000101111b: (3125275976)10111010010001111110110101001000c: (3418241791)11001011101111100011101011111111d: (2575600242)10011001100001001000101001110010

Data Block: (0)00000000000000000000000000000000R Constant: (7)00000000000000000000000000000111Sin Value: (1770035416)01101001100000001001100011011000

Logic Function: (262009391)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (211987914)00001100101000101010110111001010

MD5 Generation Iteration 1: Step 10a = d, d = c, c = b, b = previous resulting value

a: (2575600242)10011001100001001000101001110010b: (211987914)00001100101000101010110111001010c: (3125275976)10111010010001111110110101001000d: (3418241791)11001011101111100011101011111111

Data Block: (0)00000000000000000000000000000000R Constant: (12)00000000000000000000000000001100Sin Value: (2336552879)10001011010001001111011110101111

Logic Function: (2575600242)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2428280008)10010000101111001001110011001000

MD5 Generation Iteration 1: Step 11a = d, d = c, c = b, b = previous resulting value

a: (3418241791)11001011101111100011101011111111b: (2428280008)10010000101111001001110011001000c: (211987914)00001100101000101010110111001010d: (3125275976)10111010010001111110110101001000

Data Block: (0)00000000000000000000000000000000R Constant: (17)00000000000000000000000000010001Sin Value: (4294925233)11111111111111110101101110110001

Logic Function: (3418241791)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2578352651)10011001101011101000101000001011

MD5 Generation Iteration 1: Step 12a = d, d = c, c = b, b = previous resulting value

a: (3125275976)10111010010001111110110101001000b: (2578352651)10011001101011101000101000001011c: (2428280008)10010000101111001001110011001000d: (211987914)00001100101000101010110111001010

Data Block: (0)00000000000000000000000000000000R Constant: (22)00000000000000000000000000010110Sin Value: (2304563134)10001001010111001101011110111110

Logic Function: (3125275976)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1298439783)01001101011001001001111001100111

MD5 Generation Iteration 1: Step 13a = d, d = c, c = b, b = previous resulting value

a: (211987914)00001100101000101010110111001010b: (1298439783)01001101011001001001111001100111c: (2578352651)10011001101011101000101000001011d: (2428280008)10010000101111001001110011001000

Data Block: (0)00000000000000000000000000000000R Constant: (7)00000000000000000000000000000111Sin Value: (1804603682)01101011100100000001000100100010

Logic Function: (211987914)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1158240751)01000101000010010101100111101111

MD5 Generation Iteration 1: Step 14a = d, d = c, c = b, b = previous resulting value

a: (2428280008)10010000101111001001110011001000b: (1158240751)01000101000010010101100111101111c: (1298439783)01001101011001001001111001100111d: (2578352651)10011001101011101000101000001011

Data Block: (0)00000000000000000000000000000000R Constant: (12)00000000000000000000000000001100Sin Value: (4254626195)11111101100110000111000110010011

Logic Function: (2428280008)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (4287987886)11111111100101011000000010101110

MD5 Generation Iteration 1: Step 15a = d, d = c, c = b, b = previous resulting value

a: (2578352651)10011001101011101000101000001011b: (4287987886)11111111100101011000000010101110c: (1158240751)01000101000010010101100111101111d: (1298439783)01001101011001001001111001100111

Data Block: (40)00000000000000000000000000101000R Constant: (17)00000000000000000000000000010001Sin Value: (2792965006)10100110011110010100001110001110

Logic Function: (2578352651)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3640036287)11011000111101101000101110111111

MD5 Generation Iteration 1: Step 16a = d, d = c, c = b, b = previous resulting value

a: (1298439783)01001101011001001001111001100111b: (3640036287)11011000111101101000101110111111c: (4287987886)11111111100101011000000010101110d: (1158240751)01000101000010010101100111101111

Data Block: (0)00000000000000000000000000000000R Constant: (22)00000000000000000000000000010110Sin Value: (1236535329)01001001101101000000100000100001

Logic Function: (1298439783)int result = b + RotateLeft((a +(b & c) | (~b & d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3063134556)10110110100100111011100101011100

MD5 Generation Iteration 1: Step 17a = d, d = c, c = b, b = previous resulting value

a: (1158240751)01000101000010010101100111101111b: (3063134556)10110110100100111011100101011100c: (3640036287)11011000111101101000101110111111d: (4287987886)11111111100101011000000010101110

Data Block: (32879)00000000000000001000000001101111R Constant: (5)00000000000000000000000000000101Sin Value: (4129170786)11110110000111100010010101100010

Logic Function: (1158240751)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (4194637082)11111010000001010001010100011010

MD5 Generation Iteration 1: Step 18a = d, d = c, c = b, b = previous resulting value

a: (4287987886)11111111100101011000000010101110b: (4194637082)11111010000001010001010100011010c: (3063134556)10110110100100111011100101011100d: (3640036287)11011000111101101000101110111111

Data Block: (0)00000000000000000000000000000000R Constant: (9)00000000000000000000000000001001Sin Value: (3225465664)11000000010000001011001101000000

Logic Function: (4287987886)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2966398613)10110000110011111010011010010101

MD5 Generation Iteration 1: Step 19a = d, d = c, c = b, b = previous resulting value

a: (3640036287)11011000111101101000101110111111b: (2966398613)10110000110011111010011010010101c: (4194637082)11111010000001010001010100011010d: (3063134556)10110110100100111011100101011100

Data Block: (0)00000000000000000000000000000000R Constant: (14)00000000000000000000000000001110Sin Value: (643717713)00100110010111100101101001010001

Logic Function: (3640036287)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3545851020)11010011010110010110010010001100

MD5 Generation Iteration 1: Step 20a = d, d = c, c = b, b = previous resulting value

a: (3063134556)10110110100100111011100101011100b: (3545851020)11010011010110010110010010001100c: (2966398613)10110000110011111010011010010101d: (4194637082)11111010000001010001010100011010

Data Block: (1819043176)01101100011011000110010101101000R Constant: (20)00000000000000000000000000010100Sin Value: (3921069994)11101001101101101100011110101010

Logic Function: (3063134556)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2736217268)10100011000101110101110010110100

MD5 Generation Iteration 1: Step 21a = d, d = c, c = b, b = previous resulting value

a: (4194637082)11111010000001010001010100011010b: (2736217268)10100011000101110101110010110100c: (3545851020)11010011010110010110010010001100d: (2966398613)10110000110011111010011010010101

Data Block: (0)00000000000000000000000000000000R Constant: (5)00000000000000000000000000000101Sin Value: (3593408605)11010110001011110001000001011101

Logic Function: (4194637082)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (210018090)00001100100001001001111100101010

MD5 Generation Iteration 1: Step 22a = d, d = c, c = b, b = previous resulting value

a: (2966398613)10110000110011111010011010010101b: (210018090)00001100100001001001111100101010c: (2736217268)10100011000101110101110010110100d: (3545851020)11010011010110010110010010001100

Data Block: (0)00000000000000000000000000000000R Constant: (9)00000000000000000000000000001001Sin Value: (38016083)00000010010001000001010001010011

Logic Function: (2966398613)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1077076176)01000000001100101110000011010000

MD5 Generation Iteration 1: Step 23a = d, d = c, c = b, b = previous resulting value

a: (3545851020)11010011010110010110010010001100b: (1077076176)01000000001100101110000011010000c: (210018090)00001100100001001001111100101010d: (2736217268)10100011000101110101110010110100

Data Block: (0)00000000000000000000000000000000R Constant: (14)00000000000000000000000000001110Sin Value: (3634488961)11011000101000011110011010000001

Logic Function: (3545851020)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3286028019)11000011110111001100111011110011

MD5 Generation Iteration 1: Step 24a = d, d = c, c = b, b = previous resulting value

a: (2736217268)10100011000101110101110010110100b: (3286028019)11000011110111001100111011110011c: (1077076176)01000000001100101110000011010000d: (210018090)00001100100001001001111100101010

Data Block: (0)00000000000000000000000000000000R Constant: (20)00000000000000000000000000010100Sin Value: (3889429448)11100111110100111111101111001000

Logic Function: (2736217268)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (986286359)00111010110010011000100100010111

MD5 Generation Iteration 1: Step 25a = d, d = c, c = b, b = previous resulting value

a: (210018090)00001100100001001001111100101010b: (986286359)00111010110010011000100100010111c: (3286028019)11000011110111001100111011110011d: (1077076176)01000000001100101110000011010000

Data Block: (0)00000000000000000000000000000000R Constant: (5)00000000000000000000000000000101Sin Value: (568446438)00100001111000011100110111100110

Logic Function: (210018090)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2166944141)10000001001010001111000110001101

MD5 Generation Iteration 1: Step 26a = d, d = c, c = b, b = previous resulting value

a: (1077076176)01000000001100101110000011010000b: (2166944141)10000001001010001111000110001101c: (986286359)00111010110010011000100100010111d: (3286028019)11000011110111001100111011110011

Data Block: (40)00000000000000000000000000101000R Constant: (9)00000000000000000000000000001001Sin Value: (3275163606)11000011001101110000011111010110

Logic Function: (1077076176)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1753061637)01101000011111011001100100000101

MD5 Generation Iteration 1: Step 27a = d, d = c, c = b, b = previous resulting value

a: (3286028019)11000011110111001100111011110011b: (1753061637)01101000011111011001100100000101c: (2166944141)10000001001010001111000110001101d: (986286359)00111010110010011000100100010111

Data Block: (0)00000000000000000000000000000000R Constant: (14)00000000000000000000000000001110Sin Value: (4107603335)11110100110101010000110110000111

Logic Function: (3286028019)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1577021835)01011101111111110111000110001011

MD5 Generation Iteration 1: Step 28a = d, d = c, c = b, b = previous resulting value

a: (986286359)00111010110010011000100100010111b: (1577021835)01011101111111110111000110001011c: (1753061637)01101000011111011001100100000101d: (2166944141)10000001001010001111000110001101

Data Block: (0)00000000000000000000000000000000R Constant: (20)00000000000000000000000000010100Sin Value: (1163531501)01000101010110100001010011101101

Logic Function: (986286359)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (3604876188)11010110110111100000101110011100

MD5 Generation Iteration 1: Step 29a = d, d = c, c = b, b = previous resulting value

a: (2166944141)10000001001010001111000110001101b: (3604876188)11010110110111100000101110011100c: (1577021835)01011101111111110111000110001011d: (1753061637)01101000011111011001100100000101

Data Block: (0)00000000000000000000000000000000R Constant: (5)00000000000000000000000000000101Sin Value: (2850285829)10101001111000111110100100000101

Logic Function: (2166944141)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (4098265004)11110100010001101000111110101100

MD5 Generation Iteration 1: Step 30a = d, d = c, c = b, b = previous resulting value

a: (1753061637)01101000011111011001100100000101b: (4098265004)11110100010001101000111110101100c: (3604876188)11010110110111100000101110011100d: (1577021835)01011101111111110111000110001011

Data Block: (0)00000000000000000000000000000000R Constant: (9)00000000000000000000000000001001Sin Value: (4243563512)11111100111011111010001111111000

Logic Function: (1753061637)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (1524089379)01011010110101111100001000100011

MD5 Generation Iteration 1: Step 31a = d, d = c, c = b, b = previous resulting value

a: (1577021835)01011101111111110111000110001011b: (1524089379)01011010110101111100001000100011c: (4098265004)11110100010001101000111110101100d: (3604876188)11010110110111100000101110011100

Data Block: (0)00000000000000000000000000000000R Constant: (14)00000000000000000000000000001110Sin Value: (1735328473)01100111011011110000001011011001

Logic Function: (1577021835)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (2574831668)10011001011110001101000000110100

MD5 Generation Iteration 1: Step 32a = d, d = c, c = b, b = previous resulting value

a: (3604876188)11010110110111100000101110011100b: (2574831668)10011001011110001101000000110100c: (1524089379)01011010110101111100001000100011d: (4098265004)11110100010001101000111110101100

Data Block: (0)00000000000000000000000000000000R Constant: (20)00000000000000000000000000010100Sin Value: (2368359562)10001101001010100100110010001010

Logic Function: (3604876188)int result = b + RotateLeft((a + ((b & d) | (c & ~d)) + DataBlock + SinValue), R Constant)

Result after shifting: (509132245)00011110010110001011110111010101

MD5 Generation Iteration 1: Step 33a = d, d = c, c = b, b = previous resulting value

a: (4098265004)11110100010001101000111110101100b: (509132245)00011110010110001011110111010101c: (2574831668)10011001011110001101000000110100d: (1524089379)01011010110101111100001000100011

Data Block: (0)00000000000000000000000000000000R Constant: (4)00000000000000000000000000000100Sin Value: (4294588738)11111111111110100011100101000010

Logic Function: (4098265004)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (1105217762)01000001111000000100100011100010

MD5 Generation Iteration 1: Step 34a = d, d = c, c = b, b = previous resulting value

a: (1524089379)01011010110101111100001000100011b: (1105217762)01000001111000000100100011100010c: (509132245)00011110010110001011110111010101d: (2574831668)10011001011110001101000000110100

Data Block: (0)00000000000000000000000000000000R Constant: (11)00000000000000000000000000001011Sin Value: (2272392833)10000111011100011111011010000001

Logic Function: (1524089379)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2429388330)10010000110011011000011000101010

MD5 Generation Iteration 1: Step 35a = d, d = c, c = b, b = previous resulting value

a: (2574831668)10011001011110001101000000110100b: (2429388330)10010000110011011000011000101010c: (1105217762)01000001111000000100100011100010d: (509132245)00011110010110001011110111010101

Data Block: (0)00000000000000000000000000000000R Constant: (16)00000000000000000000000000010000Sin Value: (1839030562)01101101100111010110000100100010

Logic Function: (2574831668)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (893476021)00110101010000010101110010110101

MD5 Generation Iteration 1: Step 36a = d, d = c, c = b, b = previous resulting value

a: (509132245)00011110010110001011110111010101b: (893476021)00110101010000010101110010110101c: (2429388330)10010000110011011000011000101010d: (1105217762)01000001111000000100100011100010

Data Block: (40)00000000000000000000000000101000R Constant: (23)00000000000000000000000000010111Sin Value: (4259657740)11111101111001010011100000001100

Logic Function: (509132245)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2017571321)01111000010000011011000111111001

MD5 Generation Iteration 1: Step 37a = d, d = c, c = b, b = previous resulting value

a: (1105217762)01000001111000000100100011100010b: (2017571321)01111000010000011011000111111001c: (893476021)00110101010000010101110010110101d: (2429388330)10010000110011011000011000101010

Data Block: (32879)00000000000000001000000001101111R Constant: (4)00000000000000000000000000000100Sin Value: (2763975236)10100100101111101110101001000100

Logic Function: (1105217762)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (3205734837)10111111000100111010000110110101

MD5 Generation Iteration 1: Step 38a = d, d = c, c = b, b = previous resulting value

a: (2429388330)10010000110011011000011000101010b: (3205734837)10111111000100111010000110110101c: (2017571321)01111000010000011011000111111001d: (893476021)00110101010000010101110010110101

Data Block: (0)00000000000000000000000000000000R Constant: (11)00000000000000000000000000001011Sin Value: (1272893353)01001011110111101100111110101001

Logic Function: (2429388330)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (3156871210)10111100001010100000100000101010

MD5 Generation Iteration 1: Step 39a = d, d = c, c = b, b = previous resulting value

a: (893476021)00110101010000010101110010110101b: (3156871210)10111100001010100000100000101010c: (3205734837)10111111000100111010000110110101d: (2017571321)01111000010000011011000111111001

Data Block: (0)00000000000000000000000000000000R Constant: (16)00000000000000000000000000010000Sin Value: (4139469664)11110110101110110100101101100000

Logic Function: (893476021)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2091233182)01111100101001011010111110011110

MD5 Generation Iteration 1: Step 40a = d, d = c, c = b, b = previous resulting value

a: (2017571321)01111000010000011011000111111001b: (2091233182)01111100101001011010111110011110c: (3156871210)10111100001010100000100000101010d: (3205734837)10111111000100111010000110110101

Data Block: (0)00000000000000000000000000000000R Constant: (23)00000000000000000000000000010111Sin Value: (3200236656)10111110101111111011110001110000

Logic Function: (2017571321)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2986409560)10110010000000001111111001011000

MD5 Generation Iteration 1: Step 41a = d, d = c, c = b, b = previous resulting value

a: (3205734837)10111111000100111010000110110101b: (2986409560)10110010000000001111111001011000c: (2091233182)01111100101001011010111110011110d: (3156871210)10111100001010100000100000101010

Data Block: (0)00000000000000000000000000000000R Constant: (4)00000000000000000000000000000100Sin Value: (681279174)00101000100110110111111011000110

Logic Function: (3205734837)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (1441309901)01010101111010001010010011001101

MD5 Generation Iteration 1: Step 42a = d, d = c, c = b, b = previous resulting value

a: (3156871210)10111100001010100000100000101010b: (1441309901)01010101111010001010010011001101c: (2986409560)10110010000000001111111001011000d: (2091233182)01111100101001011010111110011110

Data Block: (1819043176)01101100011011000110010101101000R Constant: (11)00000000000000000000000000001011Sin Value: (3936430074)11101010101000010010011111111010

Logic Function: (3156871210)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2185060929)10000010001111010110001001000001

MD5 Generation Iteration 1: Step 43a = d, d = c, c = b, b = previous resulting value

a: (2091233182)01111100101001011010111110011110b: (2185060929)10000010001111010110001001000001c: (1441309901)01010101111010001010010011001101d: (2986409560)10110010000000001111111001011000

Data Block: (0)00000000000000000000000000000000R Constant: (16)00000000000000000000000000010000Sin Value: (3572445317)11010100111011110011000010000101

Logic Function: (2091233182)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (2603948459)10011011001101010001100110101011

MD5 Generation Iteration 1: Step 44a = d, d = c, c = b, b = previous resulting value

a: (2986409560)10110010000000001111111001011000b: (2603948459)10011011001101010001100110101011c: (2185060929)10000010001111010110001001000001d: (1441309901)01010101111010001010010011001101

Data Block: (0)00000000000000000000000000000000R Constant: (23)00000000000000000000000000010111Sin Value: (76029189)00000100100010000001110100000101

Logic Function: (2986409560)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (3711356584)11011101001101101100111010101000

MD5 Generation Iteration 1: Step 45a = d, d = c, c = b, b = previous resulting value

a: (1441309901)01010101111010001010010011001101b: (3711356584)11011101001101101100111010101000c: (2603948459)10011011001101010001100110101011d: (2185060929)10000010001111010110001001000001

Data Block: (0)00000000000000000000000000000000R Constant: (4)00000000000000000000000000000100Sin Value: (3654602809)11011001110101001101000000111001

Logic Function: (1441309901)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (486110007)00011100111110010111001100110111

MD5 Generation Iteration 1: Step 46a = d, d = c, c = b, b = previous resulting value

a: (2185060929)10000010001111010110001001000001b: (486110007)00011100111110010111001100110111c: (3711356584)11011101001101101100111010101000d: (2603948459)10011011001101010001100110101011

Data Block: (0)00000000000000000000000000000000R Constant: (11)00000000000000000000000000001011Sin Value: (3873151461)11100110110110111001100111100101

Logic Function: (2185060929)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (3120318807)10111001111111000100100101010111

MD5 Generation Iteration 1: Step 47a = d, d = c, c = b, b = previous resulting value

a: (2603948459)10011011001101010001100110101011b: (3120318807)10111001111111000100100101010111c: (486110007)00011100111110010111001100110111d: (3711356584)11011101001101101100111010101000

Data Block: (0)00000000000000000000000000000000R Constant: (16)00000000000000000000000000010000Sin Value: (530742520)00011111101000100111110011111000

Logic Function: (2603948459)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (1164409954)01000101011001110111110001100010

MD5 Generation Iteration 1: Step 48a = d, d = c, c = b, b = previous resulting value

a: (3711356584)11011101001101101100111010101000b: (1164409954)01000101011001110111110001100010c: (3120318807)10111001111111000100100101010111d: (486110007)00011100111110010111001100110111

Data Block: (0)00000000000000000000000000000000R Constant: (23)00000000000000000000000000010111Sin Value: (3299628645)11000100101011000101011001100101

Logic Function: (3711356584)int result = b + RotateLeft((a + (b ^ c ^ d) + DataBlock + SinValue), R Constant)

Result after shifting: (3441991447)11001101001010001001111100010111

MD5 Generation Iteration 1: Step 49a = d, d = c, c = b, b = previous resulting value

a: (486110007)00011100111110010111001100110111b: (3441991447)11001101001010001001111100010111c: (1164409954)01000101011001110111110001100010d: (3120318807)10111001111111000100100101010111

Data Block: (1819043176)01101100011011000110010101101000R Constant: (6)00000000000000000000000000000110Sin Value: (4096336452)11110100001010010010001001000100

Logic Function: (486110007)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (3289927448)11000100000110000100111100011000

MD5 Generation Iteration 1: Step 50a = d, d = c, c = b, b = previous resulting value

a: (3120318807)10111001111111000100100101010111b: (3289927448)11000100000110000100111100011000c: (3441991447)11001101001010001001111100010111d: (1164409954)01000101011001110111110001100010

Data Block: (0)00000000000000000000000000000000R Constant: (10)00000000000000000000000000001010Sin Value: (1126891415)01000011001010101111111110010111

Logic Function: (3120318807)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (578695131)00100010011111100010111111011011

MD5 Generation Iteration 1: Step 51a = d, d = c, c = b, b = previous resulting value

a: (1164409954)01000101011001110111110001100010b: (578695131)00100010011111100010111111011011c: (3289927448)11000100000110000100111100011000d: (3441991447)11001101001010001001111100010111

Data Block: (40)00000000000000000000000000101000R Constant: (15)00000000000000000000000000001111Sin Value: (2878612391)10101011100101000010001110100111

Logic Function: (1164409954)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (2198381516)10000011000010001010001111001100

MD5 Generation Iteration 1: Step 52a = d, d = c, c = b, b = previous resulting value

a: (3441991447)11001101001010001001111100010111b: (2198381516)10000011000010001010001111001100c: (578695131)00100010011111100010111111011011d: (3289927448)11000100000110000100111100011000

Data Block: (0)00000000000000000000000000000000R Constant: (21)00000000000000000000000000010101Sin Value: (4237533241)11111100100100111010000000111001

Logic Function: (3441991447)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (4086631815)11110011100101010000110110000111

MD5 Generation Iteration 1: Step 53a = d, d = c, c = b, b = previous resulting value

a: (3289927448)11000100000110000100111100011000b: (4086631815)11110011100101010000110110000111c: (2198381516)10000011000010001010001111001100d: (578695131)00100010011111100010111111011011

Data Block: (0)00000000000000000000000000000000R Constant: (6)00000000000000000000000000000110Sin Value: (1700485571)01100101010110110101100111000011

Logic Function: (3289927448)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (2011094832)01110111110111101101111100110000

MD5 Generation Iteration 1: Step 54a = d, d = c, c = b, b = previous resulting value

a: (578695131)00100010011111100010111111011011b: (2011094832)01110111110111101101111100110000c: (4086631815)11110011100101010000110110000111d: (2198381516)10000011000010001010001111001100

Data Block: (0)00000000000000000000000000000000R Constant: (10)00000000000000000000000000001010Sin Value: (2399980690)10001111000011001100110010010010

Logic Function: (578695131)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (1327195175)01001111000110110110010000100111

MD5 Generation Iteration 1: Step 55a = d, d = c, c = b, b = previous resulting value

a: (2198381516)10000011000010001010001111001100b: (1327195175)01001111000110110110010000100111c: (2011094832)01110111110111101101111100110000d: (4086631815)11110011100101010000110110000111

Data Block: (0)00000000000000000000000000000000R Constant: (15)00000000000000000000000000001111Sin Value: (4293915773)11111111111011111111010001111101

Logic Function: (2198381516)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (803717621)00101111111001111100000111110101

MD5 Generation Iteration 1: Step 56a = d, d = c, c = b, b = previous resulting value

a: (4086631815)11110011100101010000110110000111b: (803717621)00101111111001111100000111110101c: (1327195175)01001111000110110110010000100111d: (2011094832)01110111110111101101111100110000

Data Block: (32879)00000000000000001000000001101111R Constant: (21)00000000000000000000000000010101Sin Value: (2240044497)10000101100001000101110111010001

Logic Function: (4086631815)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (1674773699)01100011110100110000010011000011

MD5 Generation Iteration 1: Step 57a = d, d = c, c = b, b = previous resulting value

a: (2011094832)01110111110111101101111100110000b: (1674773699)01100011110100110000010011000011c: (803717621)00101111111001111100000111110101d: (1327195175)01001111000110110110010000100111

Data Block: (0)00000000000000000000000000000000R Constant: (6)00000000000000000000000000000110Sin Value: (1873313359)01101111101010000111111001001111

Logic Function: (2011094832)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (1237446707)01001001110000011111000000110011

MD5 Generation Iteration 1: Step 58a = d, d = c, c = b, b = previous resulting value

a: (1327195175)01001111000110110110010000100111b: (1237446707)01001001110000011111000000110011c: (1674773699)01100011110100110000010011000011d: (803717621)00101111111001111100000111110101

Data Block: (0)00000000000000000000000000000000R Constant: (10)00000000000000000000000000001010Sin Value: (4264355552)11111110001011001110011011100000

Logic Function: (1327195175)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (2530864208)10010110110110011110110001010000

MD5 Generation Iteration 1: Step 59a = d, d = c, c = b, b = previous resulting value

a: (803717621)00101111111001111100000111110101b: (2530864208)10010110110110011110110001010000c: (1237446707)01001001110000011111000000110011d: (1674773699)01100011110100110000010011000011

Data Block: (0)00000000000000000000000000000000R Constant: (15)00000000000000000000000000001111Sin Value: (2734768916)10100011000000010100001100010100

Logic Function: (803717621)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (554058082)00100001000001100100000101100010

MD5 Generation Iteration 1: Step 60a = d, d = c, c = b, b = previous resulting value

a: (1674773699)01100011110100110000010011000011b: (554058082)00100001000001100100000101100010c: (2530864208)10010110110110011110110001010000d: (1237446707)01001001110000011111000000110011

Data Block: (0)00000000000000000000000000000000R Constant: (21)00000000000000000000000000010101Sin Value: (1309151649)01001110000010000001000110100001

Logic Function: (1674773699)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (1700837817)01100101011000001011100110111001

MD5 Generation Iteration 1: Step 61a = d, d = c, c = b, b = previous resulting value

a: (1237446707)01001001110000011111000000110011b: (1700837817)01100101011000001011100110111001c: (554058082)00100001000001100100000101100010d: (2530864208)10010110110110011110110001010000

Data Block: (0)00000000000000000000000000000000R Constant: (6)00000000000000000000000000000110Sin Value: (4149444226)11110111010100110111111010000010

Logic Function: (1237446707)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (3271237212)11000010111110110001111001011100

MD5 Generation Iteration 1: Step 62a = d, d = c, c = b, b = previous resulting value

a: (2530864208)10010110110110011110110001010000b: (3271237212)11000010111110110001111001011100c: (1700837817)01100101011000001011100110111001d: (554058082)00100001000001100100000101100010

Data Block: (0)00000000000000000000000000000000R Constant: (10)00000000000000000000000000001010Sin Value: (3174756917)10111101001110101111001000110101

Logic Function: (2530864208)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (2190656154)10000010100100101100001010011010

MD5 Generation Iteration 1: Step 63a = d, d = c, c = b, b = previous resulting value

a: (554058082)00100001000001100100000101100010b: (2190656154)10000010100100101100001010011010c: (3271237212)11000010111110110001111001011100d: (1700837817)01100101011000001011100110111001

Data Block: (0)00000000000000000000000000000000R Constant: (15)00000000000000000000000000001111Sin Value: (718787259)00101010110101111101001010111011

Logic Function: (554058082)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (4175598779)11111000111000101001010010111011

MD5 Generation Iteration 1: Step 64a = d, d = c, c = b, b = previous resulting value

a: (1700837817)01100101011000001011100110111001b: (4175598779)11111000111000101001010010111011c: (2190656154)10000010100100101100001010011010d: (3271237212)11000010111110110001111001011100

Data Block: (0)00000000000000000000000000000000R Constant: (21)00000000000000000000000000010101Sin Value: (3951481745)11101011100001101101001110010001

Logic Function: (1700837817)int result = b + RotateLeft((a + ((c ^ (b | ~d))) + DataBlock + SinValue), R Constant)

Result after shifting: (2254217267)10000110010111001010000000110011

MD5 GenerationAfter Iteration 1: Add the new result to the previous iteration's resulth0 + A: 708854109h1 + B: 1982483388h2 + C: 2443014585h3 + D: 2462390032

MD5 GenerationAfter all iterations are completeh0: 708854109 (Hex: 5d41402a)h1: 1982483388 (Hex: bc4b2a76)h2: 2443014585 (Hex: b9719d91)h3: 2462390032 (Hex: 1017c592)

The final digest:5d41402abc4b2a76b9719d911017c592

MD5 Generation SummaryAs 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.