



'''simple docstring'''




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

class     UpperCamelCase_				:





	def __init__(						self	,	A					)    ->    Optional[Any]:
								UpperCAmelCase  :	Any							  =	data
								UpperCAmelCase  :	Dict							  =	[0X67452301, 0Xefcdab89, 0X98badcfe, 0X10325476, 0Xc3d2e1f0]





	@staticmethod
	def 				_lowercase(						A	,	A					)    ->    Dict:
								return ((n << b) | (n >> (32 - b))) & 0Xffffffff





	def 				_lowercase(						self					)    ->    str:
								UpperCAmelCase  :	Any							  =	B"""\x80""" + B"""\x00""" * (63 - (len(self.data					) + 8) % 64)
								UpperCAmelCase  :	Tuple							  =	self.data + padding + struct.pack(""">Q"""	,	8 * len(self.data					)					)
								return padded_data





	def 				_lowercase(						self					)    ->    int:
								return [
								    self.padded_data[i : i + 64] for i in range(0	,	len(self.padded_data					)	,	64					)
								]





	def 				_lowercase(						self	,	A					)    ->    Tuple:
								UpperCAmelCase  :	Union[str, Any]							  =	list(struct.unpack(""">16L"""	,	A					)					) + [0] * 64
								for i in range(16	,	80					):
															UpperCAmelCase  :	List[str]							  =	self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])	,	1					)
								return w






	def 				_lowercase(						self					)    ->    int:
								UpperCAmelCase  :	Union[str, Any]							  =	self.padding()
								UpperCAmelCase  :	Optional[int]							  =	self.split_blocks()
								for block in self.blocks:
															UpperCAmelCase  :	List[Any]							  =	self.expand_block(A					)
															UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  :	List[Any]							  =	self.h
															for i in range(0	,	80					):
																						if 0 <= i < 20:
																													UpperCAmelCase  :	List[Any]							  =	(b & c) | ((~b) & d)
																													UpperCAmelCase  :	Dict							  =	0X5a827999
																						elif 20 <= i < 40:
																													UpperCAmelCase  :	str							  =	b ^ c ^ d
																													UpperCAmelCase  :	Union[str, Any]							  =	0X6ed9eba1
																						elif 40 <= i < 60:
																													UpperCAmelCase  :	List[str]							  =	(b & c) | (b & d) | (c & d)
																													UpperCAmelCase  :	Union[str, Any]							  =	0X8f1bbcdc
																						elif 60 <= i < 80:
																													UpperCAmelCase  :	int							  =	b ^ c ^ d
																													UpperCAmelCase  :	Union[str, Any]							  =	0Xca62c1d6
																						UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  ,  UpperCAmelCase  :	int							  =	(
																						    self.rotate(A	,	5					) + f + e + k + expanded_block[i] & 0Xffffffff,
																						    a,
																						    self.rotate(A	,	30					),
																						    c,
																						    d,
																						)
															UpperCAmelCase  :	Optional[Any]							  =	(
															    self.h[0] + a & 0Xffffffff,
															    self.h[1] + b & 0Xffffffff,
															    self.h[2] + c & 0Xffffffff,
															    self.h[3] + d & 0Xffffffff,
															    self.h[4] + e & 0Xffffffff,
															)
								return ("{:08x}" * 5).format(*self.h					)




def    __lowerCamelCase						(      )   ->    List[str]:
							UpperCAmelCase  :	List[Any]							  =	B"""Test String"""
							assert SHAaHash(_lowercase	).final_hash() == hashlib.shaa(_lowercase	).hexdigest()  # noqa: S324



def    __lowerCamelCase						(      )   ->    Tuple:
							UpperCAmelCase  :	Tuple							  =	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"""	)
							UpperCAmelCase  :	List[str]							  =	parser.parse_args()
							UpperCAmelCase  :	List[Any]							  =	args.input_string
							# In any case hash input should be a bytestring
							if args.input_file:
														with open(args.input_file			,       """rb"""	) as f:
																					UpperCAmelCase  :	str							  =	f.read()
							else:
														UpperCAmelCase  :	Tuple							  =	bytes(_lowercase			,       """utf-8"""	)
							print(SHAaHash(_lowercase	).final_hash()	)


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

							doctest.testmod()






'''simple docstring'''




a     :    Tuple      						=					[sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)]



def    __lowerCamelCase						(      _lowercase	)   ->    int:
							UpperCAmelCase  :	str							  =	0
							while number:
														# Increased Speed Slightly by checking every 5 digits together.
														sum_of_digits_squared += DIGITS_SQUARED[number % 1_0_0_0_0_0]
														number //= 1_0_0_0_0_0

							return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
a     :    list[bool | None]      						=					[None] * 1_0_0_0_0_0_0_0
a     :    Optional[Any]      						=					True
a     :    List[Any]      						=					False



def    __lowerCamelCase						(      _lowercase	)   ->    bool:

							if CHAINS[number - 1] is not None:
														return CHAINS[number - 1]  # type: ignore

							UpperCAmelCase  :	List[str]							  =	chain(next_number(_lowercase	)	)
							UpperCAmelCase  :	Tuple							  =	number_chain

							while number < 1_0_0_0_0_0_0_0:
														UpperCAmelCase  :	List[str]							  =	number_chain
														number *= 1_0

							return number_chain



def    __lowerCamelCase						(      _lowercase = 1_0_0_0_0_0_0_0	)   ->    int:
							for i in range(1			,       _lowercase	):
														if CHAINS[i] is None:
																					chain(i + 1	)

							return CHAINS[:number].count(_lowercase	)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(F'''{solution() = }''')

