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





class      A							:


   def __init__(self     :						Optional[Any]       ,  __UpperCAmelCase     :						Optional[Any]		)						->				int:
         """simple docstring"""



         UpperCAmelCase__								=  data
         UpperCAmelCase__								=  [0X67_452_301, 0XEF_CDA_B89, 0X98_BAD_CFE, 0X10_325_476, 0XC3_D2E_1F0]


   @staticmethod
   def 			lowercase_      (__UpperCAmelCase     :						Optional[Any]       ,  __UpperCAmelCase     :						str		)						->				Optional[Any]:
         """simple docstring"""



         return ((n << b) | (n >> (3_2 - b))) & 0XFF_FFF_FFF


   def 			lowercase_      (self     :						Optional[int]		)						->				Tuple:
         """simple docstring"""



         UpperCAmelCase__								=  b"\x80" + b"\x00" * (6_3 - (len(self.data		) + 8) % 6_4)
         UpperCAmelCase__								=  self.data + padding + struct.pack(">Q"       ,  8 * len(self.data		)		)
         return padded_data


   def 			lowercase_      (self     :						List[str]		)						->				List[Any]:
         """simple docstring"""



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


   def 			lowercase_      (self     :						Union[str, Any]       ,  __UpperCAmelCase     :						Any		)						->				Optional[Any]:
         """simple docstring"""



         UpperCAmelCase__								=  list(struct.unpack(">16L"       ,  __UpperCAmelCase		)		) + [0] * 6_4
         for i in range(1_6       ,  8_0		):
               UpperCAmelCase__								=  self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 1_4] ^ w[i - 1_6])       ,  1		)
         return w





   def 			lowercase_      (self     :						Dict		)						->				Dict:
         """simple docstring"""



         UpperCAmelCase__								=  self.padding()
         UpperCAmelCase__								=  self.split_blocks()
         for block in self.blocks:
               UpperCAmelCase__								=  self.expand_block(__UpperCAmelCase		)
               UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__								=  self.h
               for i in range(0       ,  8_0		):
                     if 0 <= i < 2_0:
                           UpperCAmelCase__								=  (b & c) | ((~b) & d)
                           UpperCAmelCase__								=  0X5A_827_999
                     elif 2_0 <= i < 4_0:
                           UpperCAmelCase__								=  b ^ c ^ d
                           UpperCAmelCase__								=  0X6E_D9E_BA1
                     elif 4_0 <= i < 6_0:
                           UpperCAmelCase__								=  (b & c) | (b & d) | (c & d)
                           UpperCAmelCase__								=  0X8F_1BB_CDC
                     elif 6_0 <= i < 8_0:
                           UpperCAmelCase__								=  b ^ c ^ d
                           UpperCAmelCase__								=  0XCA_62C_1D6
                     UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__		,      UpperCAmelCase__								=  (
                         self.rotate(__UpperCAmelCase       ,  5		) + f + e + k + expanded_block[i] & 0XFF_FFF_FFF,
                         a,
                         self.rotate(__UpperCAmelCase       ,  3_0		),
                         c,
                         d,
                     )
               UpperCAmelCase__								=  (
                   self.h[0] + a & 0XFF_FFF_FFF,
                   self.h[1] + b & 0XFF_FFF_FFF,
                   self.h[2] + c & 0XFF_FFF_FFF,
                   self.h[3] + d & 0XFF_FFF_FFF,
                   self.h[4] + e & 0XFF_FFF_FFF,
               )
         return ("{:08x}" * 5).format(*self.h		)




def    lowerCAmelCase_ (     )     ->				Dict:







      '''simple docstring'''


      UpperCAmelCase__								=  B"Test String"
      assert SHAaHash(__A							).final_hash() == hashlib.shaa(__A							).hexdigest()  # noqa: S324




def    lowerCAmelCase_ (     )     ->				List[Any]:







      '''simple docstring'''


      UpperCAmelCase__								=  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__								=  parser.parse_args()
      UpperCAmelCase__								=  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__								=  f.read()
      else:
            UpperCAmelCase__								=  bytes(__A,  "utf-8"							)
      print(SHAaHash(__A							).final_hash()							)


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

      doctest.testmod()




from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

UpperCamelCase__											=					[
    'python',
    'tqdm',
    'regex',
    'requests',
    'packaging',
    'filelock',
    'numpy',
    'tokenizers',
    'huggingface-hub',
    'safetensors',
    'accelerate',
    'pyyaml',
]

for pkg in pkgs_to_check_at_runtime:
      if pkg in deps:
            if pkg == "tokenizers":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_tokenizers_available

                  if not is_tokenizers_available():
                        continue  # not required, check version only if installed
            elif pkg == "accelerate":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_accelerate_available

                  # Maybe switch to is_torch_available in the future here so that Accelerate is hard dep of
                  # Transformers with PyTorch
                  if not is_accelerate_available():
                        continue  # not required, check version only if installed

            require_version_core(deps[pkg])
      else:
            raise ValueError(f'''can\'t find {pkg} in {deps.keys()}, check dependency_versions_table.py''')




def    lowerCAmelCase_ (     __A,  __A=None							)     ->				Dict:







      '''simple docstring'''


      require_version(deps[pkg],  __A							)



