'''simple docstring'''
import argparse
import struct
import unittest






class 			__lowercase		:







					"""simple docstring"""






					def __init__(		self     ,			_lowerCamelCase    ):
									__UpperCamelCase	:	Optional[int]		    =  data

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

									# Initialize round constants
									__UpperCamelCase	:	Optional[int]		    =  [
									    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,
									]

									__UpperCamelCase	:	List[Any]		    =  self.preprocessing(self.data    )
									self.final_hash()







					@staticmethod
					def lowerCAmelCase     (		_lowerCamelCase    ):
									__UpperCamelCase	:	Optional[Any]		    =  b"""\x80""" + (b"""\x00""" * (6_3 - (len(A__    ) + 8) % 6_4))
									__UpperCamelCase	:	List[str]		    =  struct.pack('>Q'     ,			(len(A__    ) * 8)    )
									return data + padding + big_endian_integer







					def lowerCAmelCase     (		self    ):
									# Convert into blocks of 64 bytes
									__UpperCamelCase	:	str		    =  [
									    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
													__UpperCamelCase	:	Optional[int]		    =  list(struct.unpack('>16L'     ,			A__    )    )
													# add 48 0-ed integers
													words += [0] * 4_8

													__UpperCamelCase	:	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
																					__UpperCamelCase	:	Optional[Any]		    =  (
																					    self.ror(words[index - 1_5]     ,			7    )
																					    ^ self.ror(words[index - 1_5]     ,			1_8    )
																					    ^ (words[index - 1_5] >> 3)
																					)
																					__UpperCamelCase	:	List[str]		    =  (
																					    self.ror(words[index - 2]     ,			1_7    )
																					    ^ self.ror(words[index - 2]     ,			1_9    )
																					    ^ (words[index - 2] >> 1_0)
																					)

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

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

																	__UpperCamelCase	:	Optional[int]		    =  (
																	    g,
																	    f,
																	    e,
																	    ((d + tempa) % 0X1_0000_0000),
																	    c,
																	    b,
																	    a,
																	    ((tempa + tempa) % 0X1_0000_0000),
																	)

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

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

									__UpperCamelCase	:	List[Any]		    =  """""".join([hex(A__    )[2:].zfill(8    ) for value in self.hashes]    )







					def lowerCAmelCase     (		self     ,			_lowerCamelCase     ,			_lowerCamelCase    ):
									return 0Xffff_ffff & (value << (3_2 - rotations)) | (value >> rotations)






class 			__lowercase		(						unittest.TestCase						):







					"""simple docstring"""






					def lowerCAmelCase     (		self    ):
									import hashlib

									__UpperCamelCase	:	Optional[Any]		    =  bytes('Test String'     ,			'utf-8'    )
									self.assertEqual(SHAaaa(A__    ).hash     ,			hashlib.shaaaa(A__    ).hexdigest()    )







def  _UpperCamelCase (     ):




				"""simple docstring"""



				import doctest

				doctest.testmod()

				__UpperCamelCase	:	Any		    =  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'			)

				__UpperCamelCase	:	Dict		    =  parser.parse_args()

				__UpperCamelCase	:	List[str]		    =  args.input_string

				# hash input should be a bytestring
				if args.input_file:
								with open(args.input_file				,     'rb'			) as f:
												__UpperCamelCase	:	Union[str, Any]		    =  f.read()
				else:
								__UpperCamelCase	:	Union[str, Any]		    =  bytes(lowercase_				,     'utf-8'			)

				print(SHAaaa(lowercase_			).hash			)


if __name__ == "__main__":
		main()




'''simple docstring'''
a=  '''0.21.0'''

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
  from .utils import rich



