Hashing(SHA-1)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Example 1:

Original message 48 (01000001 00100000 01010100 01100101 0111011


011101000)

Step 1: Add 1 to the original message


48+1=49
01000001 00100000 01010100 01100101 0111011 011101000 1
Length=49
Check if length<448
448-length
If length >448
960-length
448-49=399 padding bits
Step 2: Add 399 ‘0’ to the end
01000001 00100000 01010100 01100101 0111011 011101000 1
00000000……………………………………………………………….000000000(399 padding bits)
49+399=448
Step 3: Make block of 512
512-448= 64 more bits require to make 512
Step 4: Append original message length
48=110000 (6)
64-6=58
01000001 00100000 01010100 01100101 0111011 011101000 1 (49)
(00000000……………………………………………………………….000000000)399
(000000………………..0000000)58 110000(original message)
49+399+58+6=512
Example 2:
Originla message 46113

46113+1=46114
46114/512=90.06
Take decimal part = 90 *512 =46080
46114- 46080=34
Length = 34
Length < 448 so 448-34 = 414 padding bits
46114+414=46528
Find how many block of 512 will be in 46528
46528/512= 90.875
90 block of 512 and 448 remaining bits which will become 512 by
adding 64 bits
90*512=46080
46528-46080=448
512-448=64
Original msg binary is 1011 0100 0010 0001 (16 bits)
64-16=48
Now the total blocks will be 91 (of 512) that will be processed by
SHA-1
46113+1+414+48+16=46592/512=91 blocks of 512
Apply SHA1 hashing algorithm to find the output of f1, f2 and f3 functions, If B=C2C6, C=F1B2 and
D=5FE1 in hexadecimal.

Solution

F1 F2 F3
B C D B&C !B !B&D (B&C)| B D B xor B&C B&D C&D (B&C) |
(!B&D) xor C xor (B&D) |
C D (C&D)
1 1 0 1 0 0 1 0 0 0 1 0 0 1
1 1 1 1 0 0 1 0 1 1 1 1 1 1
0 1 0 0 1 0 0 1 0 1 0 0 0 0
0 1 1 0 1 1 1 1 1 0 0 0 1 1
0 0 1 0 1 1 1 0 1 1 0 0 0 0
0 0 1 0 1 1 1 0 1 1 0 0 0 0
1 0 1 0 0 0 0 1 1 0 0 1 0 1
0 1 1 0 1 1 1 1 1 0 0 0 1 1
1 1 1 1 0 0 1 0 1 1 1 1 1 1
1 0 1 0 0 0 0 1 1 0 0 1 0 1
0 1 1 0 1 1 1 1 1 0 0 0 1 1
0 1 0 0 1 0 0 1 0 1 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 1 0 1 0 0 0 0
1 1 0 1 0 0 1 0 0 0 1 0 0 1
0 0 1 0 1 1 1 0 1 1 0 0 0 0

You might also like