





'''simple docstring'''

import argparse
import struct
import unittest







class __a			:





   def __init__(       self					:      str					,lowerCamelCase					:      bytes     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							data

      # Initialize hash values
      __SCREAMING_SNAKE_CASE   				=							[
          0x6A_09E_667,
          0xBB_67A_E85,
          0x3C_6EF_372,
          0xA5_4FF_53A,
          0x51_0E5_27F,
          0x9B_056_88C,
          0x1F_83D_9AB,
          0x5B_E0C_D19,
      ]

      # Initialize round constants
      __SCREAMING_SNAKE_CASE   				=							[
          0x42_8A2_F98,
          0x71_374_491,
          0xB5_C0F_BCF,
          0xE9_B5D_BA5,
          0x39_56C_25B,
          0x59_F11_1F1,
          0x92_3F8_2A4,
          0xAB_1C5_ED5,
          0xD8_07A_A98,
          0x12_835_B01,
          0x24_318_5BE,
          0x55_0C7_DC3,
          0x72_BE5_D74,
          0x80_DEB_1FE,
          0x9B_DC0_6A7,
          0xC1_9BF_174,
          0xE4_9B6_9C1,
          0xEF_BE4_786,
          0x0F_C19_DC6,
          0x24_0CA_1CC,
          0x2D_E92_C6F,
          0x4A_748_4AA,
          0x5C_B0A_9DC,
          0x76_F98_8DA,
          0x98_3E5_152,
          0xA8_31C_66D,
          0xB0_032_7C8,
          0xBF_597_FC7,
          0xC6_E00_BF3,
          0xD5_A79_147,
          0x06_CA6_351,
          0x14_292_967,
          0x27_B70_A85,
          0x2E_1B2_138,
          0x4D_2C6_DFC,
          0x53_380_D13,
          0x65_0A7_354,
          0x76_6A0_ABB,
          0x81_C2C_92E,
          0x92_722_C85,
          0xA2_BFE_8A1,
          0xA8_1A6_64B,
          0xC2_4B8_B70,
          0xC7_6C5_1A3,
          0xD1_92E_819,
          0xD6_990_624,
          0xF4_0E3_585,
          0x10_6AA_070,
          0x19_A4C_116,
          0x1E_376_C08,
          0x27_487_74C,
          0x34_B0B_CB5,
          0x39_1C0_CB3,
          0x4E_D8A_A4A,
          0x5B_9CC_A4F,
          0x68_2E6_FF3,
          0x74_8F8_2EE,
          0x78_A56_36F,
          0x84_C87_814,
          0x8C_C70_208,
          0x90_BEF_FFA,
          0xA4_506_CEB,
          0xBE_F9A_3F7,
          0xC6_717_8F2,
      ]

      __SCREAMING_SNAKE_CASE   				=							self.preprocessing(self.data     )
      self.final_hash()





   @staticmethod
   def   UpperCAmelCase__  (       lowerCamelCase					:      bytes     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      Tuple     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							[
          self.preprocessed_data[x : x + 64]
          for x in range(0					,len(self.preprocessed_data     )					,64     )
      ]

      for block in self.blocks:
         # Convert the given block into a list of 4 byte integers
         __SCREAMING_SNAKE_CASE   				=							list(struct.unpack(""">16L"""					,lowerCamelCase     )     )
         # add 48 0-ed integers
         words += [0] * 48

         __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							self.hashes

         for index in range(0					,64     ):
            if index > 15:
               # modify the zero-ed indexes at the end of the array
               __SCREAMING_SNAKE_CASE   				=							(
                   self.ror(words[index - 15]					,7     )
                   ^ self.ror(words[index - 15]					,18     )
                   ^ (words[index - 15] >> 3)
               )
               __SCREAMING_SNAKE_CASE   				=							(
                   self.ror(words[index - 2]					,17     )
                   ^ self.ror(words[index - 2]					,19     )
                   ^ (words[index - 2] >> 10)
               )

               __SCREAMING_SNAKE_CASE   				=							(
                   words[index - 16] + sa + words[index - 7] + sa
               ) % 0x100_000_000

            # Compression
            __SCREAMING_SNAKE_CASE   				=							self.ror(lowerCamelCase					,6     ) ^ self.ror(lowerCamelCase					,11     ) ^ self.ror(lowerCamelCase					,25     )
            __SCREAMING_SNAKE_CASE   				=							(e & f) ^ ((~e & 0xFF_FFF_FFF) & g)
            __SCREAMING_SNAKE_CASE   				=							(
                h + sa + ch + self.round_constants[index] + words[index]
            ) % 0x100_000_000
            __SCREAMING_SNAKE_CASE   				=							self.ror(lowerCamelCase					,2     ) ^ self.ror(lowerCamelCase					,13     ) ^ self.ror(lowerCamelCase					,22     )
            __SCREAMING_SNAKE_CASE   				=							(a & b) ^ (a & c) ^ (b & c)
            __SCREAMING_SNAKE_CASE   				=							(sa + maj) % 0x100_000_000

            __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							(
                g,
                f,
                e,
                ((d + tempa) % 0x100_000_000),
                c,
                b,
                a,
                ((tempa + tempa) % 0x100_000_000),
            )

         __SCREAMING_SNAKE_CASE   				=							[a, b, c, d, e, f, g, h]

         # Modify final values
         __SCREAMING_SNAKE_CASE   				=							[
             ((element + mutated_hash_values[index]) % 0x100_000_000)
             for index, element in enumerate(self.hashes     )
         ]

      __SCREAMING_SNAKE_CASE   				=							"""""".join([hex(lowerCamelCase     )[2:].zfill(8     ) for value in self.hashes]     )





   def   UpperCAmelCase__  (       self					:      Optional[Any]					,lowerCamelCase					:      int					,lowerCamelCase					:      int     ):

      '''simple docstring'''

      return 0xFF_FFF_FFF & (value << (32 - rotations)) | (value >> rotations)







class __a			( unittest.TestCase      ):





   def   UpperCAmelCase__  (       self					:      Union[str, Any]     ):

      '''simple docstring'''

      import hashlib

      __SCREAMING_SNAKE_CASE   				=							bytes("""Test String"""					,"""utf-8"""     )
      self.assertEqual(SHAaaa(lowerCamelCase     ).hash					,hashlib.shaaaa(lowerCamelCase     ).hexdigest()     )





def     __magic_name__							(				)    ->       None:

   '''simple docstring'''







   import doctest

   doctest.testmod()

   __SCREAMING_SNAKE_CASE   				=							argparse.ArgumentParser()
   parser.add_argument(
       """-s"""				,						"""--string"""				,						dest="""input_string"""				,						default="""Hello World!! Welcome to Cryptography"""				,						help="""Hash the string"""				,						)
   parser.add_argument(
       """-f"""				,						"""--file"""				,						dest="""input_file"""				,						help="""Hash contents of a file"""   )

   __SCREAMING_SNAKE_CASE   				=							parser.parse_args()

   __SCREAMING_SNAKE_CASE   				=							args.input_string

   # 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(__UpperCAmelCase				,						"""utf-8"""   )

   print(SHAaaa(__UpperCAmelCase   ).hash   )


if __name__ == "__main__":
    main()












'''simple docstring'''

from __future__ import annotations







class __a			:





   def __init__(       self					:      Optional[int]					,lowerCamelCase					:      list[list[int]]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							TypeError(
          """Matrices must be formed from a list of zero or more lists containing at """
          """least one and the same number of values, each of which must be of type """
          """int or float."""     )
      if len(lowerCamelCase     ) != 0:
         __SCREAMING_SNAKE_CASE   				=							len(rows[0]     )
         if cols == 0:
            raise error
         for row in rows:
            if len(lowerCamelCase     ) != cols:
               raise error
            for value in row:
               if not isinstance(lowerCamelCase					,(int, float)     ):
                  raise error
         __SCREAMING_SNAKE_CASE   				=							rows
      else:
         __SCREAMING_SNAKE_CASE   				=							[]





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      return [[row[i] for row in self.rows] for i in range(len(self.rows[0]     )     )]





   @property
   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      return len(self.rows     )





   @property
   def   UpperCAmelCase__  (       self					:      Union[str, Any]     ):

      '''simple docstring'''

      return len(self.rows[0]     )





   @property
   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

      return (self.num_rows, self.num_columns)





   @property
   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

      return self.order[0] == self.order[1]





   def   UpperCAmelCase__  (       self					:      List[str]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							[
          [0 if column_num != row_num else 1 for column_num in range(self.num_rows     )]
          for row_num in range(self.num_rows     )
      ]
      return Matrix(lowerCamelCase     )





   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

      if not self.is_square:
         return 0
      if self.order == (0, 0):
         return 1
      if self.order == (1, 1):
         return int(self.rows[0][0]     )
      if self.order == (2, 2):
         return int(
             (self.rows[0][0] * self.rows[1][1])
             - (self.rows[0][1] * self.rows[1][0])     )
      else:
         return sum(
             self.rows[0][column] * self.cofactors().rows[0][column]
             for column in range(self.num_columns     )     )





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      return bool(self.determinant()     )





   def   UpperCAmelCase__  (       self					:      Union[str, Any]					,lowerCamelCase					:      int					,lowerCamelCase					:      int     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							[
          [
              self.rows[other_row][other_column]
              for other_column in range(self.num_columns     )
              if other_column != column
          ]
          for other_row in range(self.num_rows     )
          if other_row != row
      ]
      return Matrix(lowerCamelCase     ).determinant()





   def   UpperCAmelCase__  (       self					:      str					,lowerCamelCase					:      int					,lowerCamelCase					:      int     ):

      '''simple docstring'''

      if (row + column) % 2 == 0:
         return self.get_minor(lowerCamelCase					,lowerCamelCase     )
      return -1 * self.get_minor(lowerCamelCase					,lowerCamelCase     )





   def   UpperCAmelCase__  (       self					:      List[Any]     ):

      '''simple docstring'''

      return Matrix(
          [
              [self.get_minor(lowerCamelCase					,lowerCamelCase     ) for column in range(self.num_columns     )]
              for row in range(self.num_rows     )
          ]     )





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

      return Matrix(
          [
              [
                  self.minors().rows[row][column]
                  if (row + column) % 2 == 0
                  else self.minors().rows[row][column] * -1
                  for column in range(self.minors().num_columns     )
              ]
              for row in range(self.minors().num_rows     )
          ]     )





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							[
          [self.cofactors().rows[column][row] for column in range(self.num_columns     )]
          for row in range(self.num_rows     )
      ]
      return Matrix(lowerCamelCase     )





   def   UpperCAmelCase__  (       self					:      Optional[int]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.determinant()
      if not determinant:
         raise TypeError("""Only matrices with a non-zero determinant have an inverse"""     )
      return self.adjugate() * (1 / determinant)





   def __repr__(       self					:      List[Any]     ):

      '''simple docstring'''

      return str(self.rows     )





   def __str__(       self					:      List[str]     ):

      '''simple docstring'''

      if self.num_rows == 0:
         return "[]"
      if self.num_rows == 1:
         return "[[" + ". ".join(str(self.rows[0]     )     ) + "]]"
      return (
          "["
          + "\n ".join(
              [
                  """[""" + """. """.join([str(lowerCamelCase     ) for value in row]     ) + """.]"""
                  for row in self.rows
              ]     )
          + "]"
      )





   def   UpperCAmelCase__  (       self					:      Dict					,lowerCamelCase					:      list[int]					,lowerCamelCase					:      int | None = None     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							TypeError("""Row must be a list containing all ints and/or floats"""     )
      if not isinstance(lowerCamelCase					,lowerCamelCase     ):
         raise type_error
      for value in row:
         if not isinstance(lowerCamelCase					,(int, float)     ):
            raise type_error
      if len(lowerCamelCase     ) != self.num_columns:
         raise ValueError(
             """Row must be equal in length to the other rows in the matrix"""     )
      if position is None:
         self.rows.append(lowerCamelCase     )
      else:
         __SCREAMING_SNAKE_CASE   				=							self.rows[0:position] + [row] + self.rows[position:]





   def   UpperCAmelCase__  (       self					:      Tuple					,lowerCamelCase					:      list[int]					,lowerCamelCase					:      int | None = None     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							TypeError(
          """Column must be a list containing all ints and/or floats"""     )
      if not isinstance(lowerCamelCase					,lowerCamelCase     ):
         raise type_error
      for value in column:
         if not isinstance(lowerCamelCase					,(int, float)     ):
            raise type_error
      if len(lowerCamelCase     ) != self.num_rows:
         raise ValueError(
             """Column must be equal in length to the other columns in the matrix"""     )
      if position is None:
         __SCREAMING_SNAKE_CASE   				=							[self.rows[i] + [column[i]] for i in range(self.num_rows     )]
      else:
         __SCREAMING_SNAKE_CASE   				=							[
             self.rows[i][0:position] + [column[i]] + self.rows[i][position:]
             for i in range(self.num_rows     )
         ]





   def __eq__(       self					:      int					,lowerCamelCase					:      object     ):

      '''simple docstring'''

      if not isinstance(lowerCamelCase					,lowerCamelCase     ):
         return NotImplemented
      return self.rows == other.rows





   def __ne__(       self					:      Any					,lowerCamelCase					:      object     ):

      '''simple docstring'''

      return not self == other





   def __neg__(       self					:      Any     ):

      '''simple docstring'''

      return self * -1





   def __add__(       self					:      List[Any]					,lowerCamelCase					:      Matrix     ):

      '''simple docstring'''

      if self.order != other.order:
         raise ValueError("""Addition requires matrices of the same order"""     )
      return Matrix(
          [
              [self.rows[i][j] + other.rows[i][j] for j in range(self.num_columns     )]
              for i in range(self.num_rows     )
          ]     )





   def __sub__(       self					:      Any					,lowerCamelCase					:      Matrix     ):

      '''simple docstring'''

      if self.order != other.order:
         raise ValueError("""Subtraction requires matrices of the same order"""     )
      return Matrix(
          [
              [self.rows[i][j] - other.rows[i][j] for j in range(self.num_columns     )]
              for i in range(self.num_rows     )
          ]     )





   def __mul__(       self					:      Any					,lowerCamelCase					:      Matrix | int | float     ):

      '''simple docstring'''

      if isinstance(lowerCamelCase					,(int, float)     ):
         return Matrix(
             [[int(element * other     ) for element in row] for row in self.rows]     )
      elif isinstance(lowerCamelCase					,lowerCamelCase     ):
         if self.num_columns != other.num_rows:
            raise ValueError(
                """The number of columns in the first matrix must """
                """be equal to the number of rows in the second"""     )
         return Matrix(
             [
                 [Matrix.dot_product(lowerCamelCase					,lowerCamelCase     ) for column in other.columns()]
                 for row in self.rows
             ]     )
      else:
         raise TypeError(
             """A Matrix can only be multiplied by an int, float, or another matrix"""     )





   def __pow__(       self					:      Optional[int]					,lowerCamelCase					:      int     ):

      '''simple docstring'''

      if not isinstance(lowerCamelCase					,lowerCamelCase     ):
         raise TypeError("""A Matrix can only be raised to the power of an int"""     )
      if not self.is_square:
         raise ValueError("""Only square matrices can be raised to a power"""     )
      if other == 0:
         return self.identity()
      if other < 0:
         if self.is_invertable():
            return self.inverse() ** (-other)
         raise ValueError(
             """Only invertable matrices can be raised to a negative power"""     )
      __SCREAMING_SNAKE_CASE   				=							self
      for _ in range(other - 1     ):
         result *= self
      return result





   @classmethod
   def   UpperCAmelCase__  (       cls					:      str					,lowerCamelCase					:      list[int]					,lowerCamelCase					:      list[int]     ):

      '''simple docstring'''

      return sum(row[i] * column[i] for i in range(len(lowerCamelCase     )     )     )


if __name__ == "__main__":
    import doctest

    doctest.testmod()





