
import argparse
import struct
import unittest



class 		UpperCamelCase__  :
   def __init__(self			: int ,    snake_case_			: bytes       ):
    __a			:  Dict		    =  data

    # Initialize hash values
    __a			:  Dict		    =  [
        0X6a09_e667,
        0Xbb67_ae85,
        0X3c6e_f372,
        0Xa54f_f53a,
        0X510e_527f,
        0X9b05_688c,
        0X1f83_d9ab,
        0X5be0_cd19,
    ]

    # Initialize round constants
    __a			:  Union[str, Any]		    =  [
        0X428a_2f98,
        0X7137_4491,
        0Xb5c0_fbcf,
        0Xe9b5_dba5,
        0X3956_c25b,
        0X59f1_11f1,
        0X923f_82a4,
        0Xab1c_5ed5,
        0Xd807_aa98,
        0X1283_5b01,
        0X2431_85be,
        0X550c_7dc3,
        0X72be_5d74,
        0X80de_b1fe,
        0X9bdc_06a7,
        0Xc19b_f174,
        0Xe49b_69c1,
        0Xefbe_4786,
        0X0fc1_9dc6,
        0X240c_a1cc,
        0X2de9_2c6f,
        0X4a74_84aa,
        0X5cb0_a9dc,
        0X76f9_88da,
        0X983e_5152,
        0Xa831_c66d,
        0Xb003_27c8,
        0Xbf59_7fc7,
        0Xc6e0_0bf3,
        0Xd5a7_9147,
        0X06ca_6351,
        0X1429_2967,
        0X27b7_0a85,
        0X2e1b_2138,
        0X4d2c_6dfc,
        0X5338_0d13,
        0X650a_7354,
        0X766a_0abb,
        0X81c2_c92e,
        0X9272_2c85,
        0Xa2bf_e8a1,
        0Xa81a_664b,
        0Xc24b_8b70,
        0Xc76c_51a3,
        0Xd192_e819,
        0Xd699_0624,
        0Xf40e_3585,
        0X106a_a070,
        0X19a4_c116,
        0X1e37_6c08,
        0X2748_774c,
        0X34b0_bcb5,
        0X391c_0cb3,
        0X4ed8_aa4a,
        0X5b9c_ca4f,
        0X682e_6ff3,
        0X748f_82ee,
        0X78a5_636f,
        0X84c8_7814,
        0X8cc7_0208,
        0X90be_fffa,
        0Xa450_6ceb,
        0Xbef9_a3f7,
        0Xc671_78f2,
    ]

    __a			:  List[str]		    =  self.preprocessing(self.data       )
    self.final_hash()
   @staticmethod
   def 				lowerCAmelCase      (snake_case_			: bytes       ):
    __a			:  Optional[Any]		    =  B'''\x80''' + (B'''\x00''' * (6_3 - (len(snake_case_       ) + 8) % 6_4))
    __a			:  Dict		    =  struct.pack('''>Q''' ,    (len(snake_case_       ) * 8)       )
    return data + padding + big_endian_integer
   def 				lowerCAmelCase      (self			: Union[str, Any]       ):
    # Convert into blocks of 64 bytes
    __a			:  Tuple		    =  [
        self.preprocessed_data[x : x + 6_4]
        for x in range(0 ,    len(self.preprocessed_data       ) ,    6_4       )
    ]

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

     __a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a			:  Optional[Any]		    =  self.hashes

     for index in range(0 ,    6_4       ):
      if index > 1_5:
       # modify the zero-ed indexes at the end of the array
       __a			:  List[Any]		    =  (
           self.ror(words[index - 1_5] ,    7       )
           ^ self.ror(words[index - 1_5] ,    1_8       )
           ^ (words[index - 1_5] >> 3)
       )
       __a			:  str		    =  (
           self.ror(words[index - 2] ,    1_7       )
           ^ self.ror(words[index - 2] ,    1_9       )
           ^ (words[index - 2] >> 1_0)
       )

       __a			:  List[Any]		    =  (
           words[index - 1_6] + sa + words[index - 7] + sa
       ) % 0X1_0000_0000

      # Compression
      __a			:  int		    =  self.ror(snake_case_ ,    6       ) ^ self.ror(snake_case_ ,    1_1       ) ^ self.ror(snake_case_ ,    2_5       )
      __a			:  Tuple		    =  (e & f) ^ ((~e & 0Xffff_ffff) & g)
      __a			:  Any		    =  (
          h + sa + ch + self.round_constants[index] + words[index]
      ) % 0X1_0000_0000
      __a			:  Tuple		    =  self.ror(snake_case_ ,    2       ) ^ self.ror(snake_case_ ,    1_3       ) ^ self.ror(snake_case_ ,    2_2       )
      __a			:  int		    =  (a & b) ^ (a & c) ^ (b & c)
      __a			:  Optional[Any]		    =  (sa + maj) % 0X1_0000_0000

      __a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a    ,	__a			:  Any		    =  (
          g,
          f,
          e,
          ((d + tempa) % 0X1_0000_0000),
          c,
          b,
          a,
          ((tempa + tempa) % 0X1_0000_0000),
      )

     __a			:  List[Any]		    =  [a, b, c, d, e, f, g, h]

     # Modify final values
     __a			:  Union[str, Any]		    =  [
         ((element + mutated_hash_values[index]) % 0X1_0000_0000)
         for index, element in enumerate(self.hashes       )
     ]

    __a			:  Optional[int]		    =  ''''''.join([hex(snake_case_       )[2:].zfill(8       ) for value in self.hashes]       )







   def 				lowerCAmelCase      (self			: List[Any] ,    snake_case_			: int ,    snake_case_			: int       ):
    return 0Xffff_ffff & (value << (3_2 - rotations)) | (value >> rotations)





class 		UpperCamelCase__  (	unittest.TestCase   ):
   def 				lowerCAmelCase      (self			: List[str]       ):
    import hashlib

    __a			:  List[Any]		    =  bytes('''Test String''' ,    '''utf-8'''       )
    self.assertEqual(SHAaaa(snake_case_       ).hash ,    hashlib.shaaaa(snake_case_       ).hexdigest()       )





def        __UpperCamelCase					(    ):
 import doctest

 doctest.testmod()

 __a			:  Optional[int]		    =  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'''  )

 __a			:  Tuple		    =  parser.parse_args()

 __a			:  int		    =  args.input_string

 # 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			:  str		    =  bytes(lowerCAmelCase__  ,       '''utf-8'''  )

 print(SHAaaa(lowerCAmelCase__  ).hash  )


if __name__ == "__main__":
      main()


def        __UpperCamelCase					(    lowerCAmelCase__							:    str  ,       lowerCAmelCase__							:    str  ):
 __a			:  Any		    =  len(lowerCAmelCase__  )
 __a			:  Union[str, Any]		    =  []
 for i in range(len(lowerCAmelCase__  ) - pat_len + 1  ):
  __a			:  List[Any]		    =  True
  for j in range(lowerCAmelCase__  ):
   if s[i + j] != pattern[j]:
    __a			:  Union[str, Any]		    =  False
    break
  if match_found:
   position.append(lowerCAmelCase__  )
 return position


if __name__ == "__main__":
      assert naive_pattern_search('ABCDEFG', 'DE') == [3]
      print(naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC'))
