This repository was archived by the owner on Jun 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
1
from Input_Padder import InputPadder
2
+ from Padded_Parser import InputParser
2
3
3
4
input_string = str (input ("Enter the data: " ))
4
5
5
6
padded_input_string = InputPadder (input_string ).pad_input ()
6
7
7
- print ("Padded Input String: " , padded_input_string )
8
+ print ("Padded Input String: " , padded_input_string )
9
+
10
+ expanded_message_schedule = InputParser (padded_input_string ).process_chunks ()
11
+
12
+ print ("Expanded Message Schedule: " , expanded_message_schedule )
Original file line number Diff line number Diff line change
1
+ import struct
2
+ from Right_Rotator import RightRotator
3
+
4
+ class InputParser :
5
+ def __init__ (self , input_data ):
6
+ self .input_data = input_data
7
+
8
+ def process_chunks (self ):
9
+ result = []
10
+ for i in range (0 , len (self .input_data ), 64 ):
11
+ chunk = self .input_data [i :i + 64 ]
12
+ w = list (struct .unpack ('>16L' , chunk )) + [0 ] * 48
13
+ for i in range (16 , 64 ):
14
+ s0 = RightRotator (w [i - 15 ], 7 ).right_rotate () ^ RightRotator (w [i - 15 ], 18 ).right_rotate () ^ (w [i - 15 ] >> 3 )
15
+ s1 = RightRotator (w [i - 2 ], 17 ).right_rotate () ^ RightRotator (w [i - 2 ], 19 ).right_rotate () ^ (w [i - 2 ] >> 10 )
16
+ w [i ] = (w [i - 16 ] + s0 + w [i - 7 ] + s1 ) & 0xFFFFFFFF
17
+
18
+ result .append (w )
19
+
20
+ return result
Original file line number Diff line number Diff line change
1
+ class RightRotator :
2
+ def __init__ (self , value , bits ):
3
+ self .value = value
4
+ self .bits = bits
5
+
6
+ def right_rotate (self ):
7
+ return ((self .value >> self .bits ) | (self .value << (32 - self .bits ))) & 0xFFFFFFFF
You can’t perform that action at this time.
0 commit comments