
'''simple docstring'''





import argparse
import hashlib  # hashlib is only used inside the Test class
import struct




class 			_snake_case		:




			def __init__( self    ,							a__							)    ->    str:

										'''simple docstring'''




										snake_case_      =				data
										snake_case_      =				[0X6_7_4_5_2_3_0_1, 0XE_F_C_D_A_B_8_9, 0X9_8_B_A_D_C_F_E, 0X1_0_3_2_5_4_7_6, 0XC_3_D_2_E_1_F_0]




			@staticmethod
			def        lowerCAmelCase__    ( a__    ,							a__							)    ->    int:

										'''simple docstring'''




										return ((n << b) | (n >> (32 - b))) & 0XF_F_F_F_F_F_F_F




			def        lowerCAmelCase__    ( self							)    ->    Dict:

										'''simple docstring'''




										snake_case_      =				b"\x80" + b"\x00" * (63 - (len(self.data							) + 8) % 64)
										snake_case_      =				self.data + padding + struct.pack(">Q"    ,							8 * len(self.data							)							)
										return padded_data




			def        lowerCAmelCase__    ( self							)    ->    int:

										'''simple docstring'''




										return [
										    self.padded_data[i : i + 64] for i in range(0    ,							len(self.padded_data							)    ,							64							)
										]




			def        lowerCAmelCase__    ( self    ,							a__							)    ->    Optional[Any]:

										'''simple docstring'''




										snake_case_      =				list(struct.unpack(">16L"    ,							_SCREAMING_SNAKE_CASE							)							) + [0] * 64
										for i in range(16    ,							80							):
																	snake_case_      =				self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])    ,							1							)
										return w




			def        lowerCAmelCase__    ( self							)    ->    List[Any]:

										'''simple docstring'''




										snake_case_      =				self.padding()
										snake_case_      =				self.split_blocks()
										for block in self.blocks:
																	snake_case_      =				self.expand_block(_SCREAMING_SNAKE_CASE							)
																	snake_case_      =				self.h
																	for i in range(0    ,							80							):
																								if 0 <= i < 20:
																															snake_case_      =				(b & c) | ((~b) & d)
																															snake_case_      =				0X5_A_8_2_7_9_9_9
																								elif 20 <= i < 40:
																															snake_case_      =				b ^ c ^ d
																															snake_case_      =				0X6_E_D_9_E_B_A_1
																								elif 40 <= i < 60:
																															snake_case_      =				(b & c) | (b & d) | (c & d)
																															snake_case_      =				0X8_F_1_B_B_C_D_C
																								elif 60 <= i < 80:
																															snake_case_      =				b ^ c ^ d
																															snake_case_      =				0XC_A_6_2_C_1_D_6
																								snake_case_      =				(
																								    self.rotate(_SCREAMING_SNAKE_CASE    ,							5							) + f + e + k + expanded_block[i] & 0XF_F_F_F_F_F_F_F,
																								    a,
																								    self.rotate(_SCREAMING_SNAKE_CASE    ,							30							),
																								    c,
																								    d,
																								)
																	snake_case_      =				(
																	    self.h[0] + a & 0XF_F_F_F_F_F_F_F,
																	    self.h[1] + b & 0XF_F_F_F_F_F_F_F,
																	    self.h[2] + c & 0XF_F_F_F_F_F_F_F,
																	    self.h[3] + d & 0XF_F_F_F_F_F_F_F,
																	    self.h[4] + e & 0XF_F_F_F_F_F_F_F,
																	)
										return ("{:08x}" * 5).format(*self.h							)


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							snake_case_      =				B"Test String"
							assert SHAaHash(__snake_case					).final_hash() == hashlib.shaa(__snake_case					).hexdigest()  # noqa: S324


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							snake_case_      =				argparse.ArgumentParser(description="Process some strings or files"					)
							parser.add_argument(
							    "--string"							,    dest="input_string"							,    default="Hello World!! Welcome to Cryptography"							,    help="Hash the string"							,    )
							parser.add_argument("--file"							,    dest="input_file"							,    help="Hash contents of a file"					)
							snake_case_      =				parser.parse_args()
							snake_case_      =				args.input_string
							# In any case hash input should be a bytestring
							if args.input_file:
														with open(args.input_file							,    "rb"					) as f:
																					snake_case_      =				f.read()
							else:
														snake_case_      =				bytes(__snake_case							,    "utf-8"					)
							print(SHAaHash(__snake_case					).final_hash()					)


if __name__ == "__main__":
		main()
		import doctest

		doctest.testmod()










'''simple docstring'''





def 					UpperCamelCase_(     snake_case							:	list[int]							,    snake_case							:	int					):

							'''simple docstring'''






							snake_case_      =				len(snake_case					)
							snake_case_      =				[[False] * (required_sum + 1) for _ in range(arr_len + 1					)]

							# for each arr value, a sum of zero(0) can be formed by not taking any element
							# hence True/1
							for i in range(arr_len + 1					):
														snake_case_      =				True

							# sum is not zero and set is empty then false
							for i in range(1							,    required_sum + 1					):
														snake_case_      =				False

							for i in range(1							,    arr_len + 1					):
														for j in range(1							,    required_sum + 1					):
																					if arr[i - 1] > j:
																												snake_case_      =				subset[i - 1][j]
																					if arr[i - 1] <= j:
																												snake_case_      =				subset[i - 1][j] or subset[i - 1][j - arr[i - 1]]

							return subset[arr_len][required_sum]


if __name__ == "__main__":
		import doctest

		doctest.testmod()




