


'''simple docstring'''


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



class 	__lowerCAmelCase		:


  '''simple docstring'''







  def __init__(							self :       str	,_a :       Any ):

        '''simple docstring'''




        A_						:  Optional[int]          =				data
        A_						:  Optional[Any]          =				[0X67452301, 0XEFCDAB89, 0X98BADCFE, 0X10325476, 0XC3D2E1F0]






  @staticmethod
  def        _a							(							_a :       Dict	,_a :       Tuple ):

        '''simple docstring'''




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






  def        _a							(							self :       Tuple ):

        '''simple docstring'''




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






  def        _a							(							self :       Optional[Any] ):

        '''simple docstring'''




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






  def        _a							(							self :       Union[str, Any]	,_a :       Tuple ):

        '''simple docstring'''




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






  def        _a							(							self :       Tuple ):

        '''simple docstring'''




        A_						:  Optional[int]          =				self.padding()
        A_						:  Union[str, Any]          =				self.split_blocks()
        for block in self.blocks:
              A_						:  Tuple          =				self.expand_block(_a )
              A_   ,					A_   ,					A_   ,					A_   ,					A_						:  str          =				self.h
              for i in range(0	,80 ):
                    if 0 <= i < 20:
                          A_						:  Optional[Any]          =				(b & c) | ((~b) & d)
                          A_						:  str          =				0X5A827999
                    elif 20 <= i < 40:
                          A_						:  int          =				b ^ c ^ d
                          A_						:  Union[str, Any]          =				0X6ED9EBA1
                    elif 40 <= i < 60:
                          A_						:  List[Any]          =				(b & c) | (b & d) | (c & d)
                          A_						:  Union[str, Any]          =				0X8F1BBCDC
                    elif 60 <= i < 80:
                          A_						:  List[str]          =				b ^ c ^ d
                          A_						:  Tuple          =				0XCA62C1D6
                    A_   ,					A_   ,					A_   ,					A_   ,					A_						:  Tuple          =				(
                        self.rotate(_a	,5 ) + f + e + k + expanded_block[i] & 0XFFFFFFFF,
                        a,
                        self.rotate(_a	,30 ),
                        c,
                        d,
                    )
              A_						:  Union[str, 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					(      ):
      A_						:  Union[str, Any]          =				b"""Test String"""
      assert SHAaHash(lowerCamelCase).final_hash() == hashlib.shaa(lowerCamelCase).hexdigest()  # noqa: S324




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


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

     doctest.testmod()




'''simple docstring'''


from ..utils import DummyObject, requires_backends



class 	__lowerCAmelCase		(							metaclass=__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							["""torch""", """torchsde"""]






  def __init__(							self :       Any	,*_a :       Union[str, Any]	,**_a :       Optional[int] ):

        '''simple docstring'''




        requires_backends(self	,["""torch""", """torchsde"""] )






  @classmethod
  def        _a							(							cls :       Optional[int]	,*_a :       List[Any]	,**_a :       Any ):

        '''simple docstring'''




        requires_backends(cls	,["""torch""", """torchsde"""] )






  @classmethod
  def        _a							(							cls :       List[Any]	,*_a :       Tuple	,**_a :       Union[str, Any] ):

        '''simple docstring'''




        requires_backends(cls	,["""torch""", """torchsde"""] )
