




"""simple docstring"""


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


class _lowerCamelCase    :






   def __init__(		self       :		Tuple   ,     UpperCamelCase       :		Dict   )			->						Optional[int]:

         """simple docstring"""
         lowerCAmelCase__      :			Optional[Any]   =	data
         lowerCAmelCase__      :			Tuple   =	[0X67_45_23_01, 0Xef_cd_ab_89, 0X98_ba_dc_fe, 0X10_32_54_76, 0Xc3_d2_e1_f0]






   @staticmethod
   def 	_lowerCAmelCase   (		UpperCamelCase       :		Dict   ,     UpperCamelCase       :		Union[str, Any]   )			->						List[str]:

         """simple docstring"""
         return ((n << b) | (n >> (32 - b))) & 0Xff_ff_ff_ff






   def 	_lowerCAmelCase   (		self       :		List[Any]   )			->						Optional[int]:

         """simple docstring"""
         lowerCAmelCase__      :			Union[str, Any]   =	b"""\x80""" + b"""\x00""" * (63 - (len(self.data   ) + 8) % 64)
         lowerCAmelCase__      :			str   =	self.data + padding + struct.pack(""">Q"""   ,     8 * len(self.data   )   )
         return padded_data






   def 	_lowerCAmelCase   (		self       :		Any   )			->						int:

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






   def 	_lowerCAmelCase   (		self       :		Optional[Any]   ,     UpperCamelCase       :		List[Any]   )			->						Any:

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






   def 	_lowerCAmelCase   (		self       :		Union[str, Any]   )			->						List[Any]:

         """simple docstring"""
         lowerCAmelCase__      :			List[Any]   =	self.padding()
         lowerCAmelCase__      :			Optional[Any]   =	self.split_blocks()
         for block in self.blocks:
               lowerCAmelCase__      :			int   =	self.expand_block(UpperCamelCase   )
               lowerCAmelCase__      :			int   =	self.h
               for i in range(0   ,     80   ):
                     if 0 <= i < 20:
                           lowerCAmelCase__      :			List[str]   =	(b & c) | ((~b) & d)
                           lowerCAmelCase__      :			Union[str, Any]   =	0X5a_82_79_99
                     elif 20 <= i < 40:
                           lowerCAmelCase__      :			List[str]   =	b ^ c ^ d
                           lowerCAmelCase__      :			Dict   =	0X6e_d9_eb_a1
                     elif 40 <= i < 60:
                           lowerCAmelCase__      :			List[str]   =	(b & c) | (b & d) | (c & d)
                           lowerCAmelCase__      :			int   =	0X8f_1b_bc_dc
                     elif 60 <= i < 80:
                           lowerCAmelCase__      :			Union[str, Any]   =	b ^ c ^ d
                           lowerCAmelCase__      :			Optional[Any]   =	0Xca_62_c1_d6
                     lowerCAmelCase__      :			Optional[int]   =	(
                         self.rotate(UpperCamelCase   ,     5   ) + f + e + k + expanded_block[i] & 0Xff_ff_ff_ff,
                         a,
                         self.rotate(UpperCamelCase   ,     30   ),
                         c,
                         d,
                     )
               lowerCAmelCase__      :			Union[str, Any]   =	(
                   self.h[0] + a & 0Xff_ff_ff_ff,
                   self.h[1] + b & 0Xff_ff_ff_ff,
                   self.h[2] + c & 0Xff_ff_ff_ff,
                   self.h[3] + d & 0Xff_ff_ff_ff,
                   self.h[4] + e & 0Xff_ff_ff_ff,
               )
         return ("{:08x}" * 5).format(*self.h   )






def 	lowercase_				(			)						->    Optional[Any]:






      """simple docstring"""




      lowerCAmelCase__      :			Dict   =	B"""Test String"""
      assert SHAaHash(__UpperCAmelCase				).final_hash() == hashlib.shaa(__UpperCAmelCase				).hexdigest()  # noqa: S324



def 	lowercase_				(			)						->    List[str]:






      """simple docstring"""




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


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

  doctest.testmod()











"""simple docstring"""


def 	lowercase_				(			__UpperCAmelCase    ,		__UpperCAmelCase				)						->    str:
      return "\n".join(
          f"""{number} * {i} = {number * i}""" for i in range(1    ,		number_of_terms + 1				)				)


if __name__ == "__main__":
  print(multiplication_table(number=5, number_of_terms=1_0))





