


"""simple docstring"""







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




class  UpperCamelCase_	:

	"""simple docstring"""





	def __init__( self			:				List[Any]			,			UpperCAmelCase__			:				List[str]   )       ->	int:
						__SCREAMING_SNAKE_CASE						   =				data
						__SCREAMING_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   UpperCAmelCase_      ( UpperCAmelCase__			:				Optional[Any]			,			UpperCAmelCase__			:				Dict   )       ->	Tuple:
						return ((n << b) | (n >> (3_2 - b))) & 0xf_f_f_f_f_f_f_f




	def   UpperCAmelCase_      ( self			:				List[Any]   )       ->	List[Any]:
						__SCREAMING_SNAKE_CASE						   =				B"""\x80""" + B"""\x00""" * (6_3 - (len(self.data   ) + 8) % 6_4)
						__SCREAMING_SNAKE_CASE						   =				self.data + padding + struct.pack(">Q"			,			8 * len(self.data   )   )
						return padded_data




	def   UpperCAmelCase_      ( self			:				Union[str, Any]   )       ->	List[Any]:
						return [
						    self.padded_data[i : i + 6_4] for i in range(0			,			len(self.padded_data   )			,			6_4   )
						]




	def   UpperCAmelCase_      ( self			:				Optional[Any]			,			UpperCAmelCase__			:				List[Any]   )       ->	Optional[Any]:
						__SCREAMING_SNAKE_CASE						   =				list(struct.unpack(">16L"			,			a_   )   ) + [0] * 6_4
						for i in range(1_6			,			8_0   ):
											__SCREAMING_SNAKE_CASE						   =				self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 1_4] ^ w[i - 1_6])			,			1   )
						return w




	def   UpperCAmelCase_      ( self			:				int   )       ->	List[Any]:
						__SCREAMING_SNAKE_CASE						   =				self.padding()
						__SCREAMING_SNAKE_CASE						   =				self.split_blocks()
						for block in self.blocks:
											__SCREAMING_SNAKE_CASE						   =				self.expand_block(a_   )
											__SCREAMING_SNAKE_CASE						   =				self.h
											for i in range(0			,			8_0   ):
																if 0 <= i < 2_0:
																					__SCREAMING_SNAKE_CASE						   =				(b & c) | ((~b) & d)
																					__SCREAMING_SNAKE_CASE						   =				0x5_a_8_2_7_9_9_9
																elif 2_0 <= i < 4_0:
																					__SCREAMING_SNAKE_CASE						   =				b ^ c ^ d
																					__SCREAMING_SNAKE_CASE						   =				0x6_e_d_9_e_b_a_1
																elif 4_0 <= i < 6_0:
																					__SCREAMING_SNAKE_CASE						   =				(b & c) | (b & d) | (c & d)
																					__SCREAMING_SNAKE_CASE						   =				0x8_f_1_b_b_c_d_c
																elif 6_0 <= i < 8_0:
																					__SCREAMING_SNAKE_CASE						   =				b ^ c ^ d
																					__SCREAMING_SNAKE_CASE						   =				0xc_a_6_2_c_1_d_6
																__SCREAMING_SNAKE_CASE						   =				(
																    self.rotate(a_			,			5   ) + f + e + k + expanded_block[i] & 0xf_f_f_f_f_f_f_f,
																    a,
																    self.rotate(a_			,			3_0   ),
																    c,
																    d,
																)
											__SCREAMING_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'''


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




def    UpperCAmelCase__       ():




					'''simple docstring'''


					__SCREAMING_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"   )
					__SCREAMING_SNAKE_CASE						   =				parser.parse_args()
					__SCREAMING_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:
															__SCREAMING_SNAKE_CASE						   =				f.read()
					else:
										__SCREAMING_SNAKE_CASE						   =				bytes(snake_case__  ,						"utf-8"   )
					print(SHAaHash(snake_case__   ).final_hash()   )


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

		doctest.testmod()






"""simple docstring"""


from ..utils import DummyObject, requires_backends






class 					lowercase(     metaclass=__a ):







 '''simple docstring'''





 lowercase__ 					=					["note_seq"]


 def __init__(				self:		Dict,      *a_:		Union[str, Any],      **a_:		List[str]		):




   '''simple docstring'''



   requires_backends(self,      ["""note_seq"""]		)


 @classmethod
 def  UpperCamelCase_   (				cls:		Optional[int],      *a_:		Any,      **a_:		Optional[Any]		):




   '''simple docstring'''



   requires_backends(cls,      ["""note_seq"""]		)


 @classmethod
 def  UpperCamelCase_   (				cls:		Tuple,      *a_:		Optional[Any],      **a_:		List[str]		):




   '''simple docstring'''



   requires_backends(cls,      ["""note_seq"""]		)


