





import argparse
import struct
import unittest



class    _a     :






							"""simple docstring"""

							def __init__(      self				:     Union[str, Any]							,	a				:     bytes    )	->None:
														SCREAMING_SNAKE_CASE__     :				int   =					data

														# Initialize hash values
														SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					[
														    0X6A09_E667,
														    0XBB67_AE85,
														    0X3C6E_F372,
														    0XA54F_F53A,
														    0X510E_527F,
														    0X9B05_688C,
														    0X1F83_D9AB,
														    0X5BE0_CD19,
														]

														# Initialize round constants
														SCREAMING_SNAKE_CASE__     :				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,
														]

														SCREAMING_SNAKE_CASE__     :				int   =					self.preprocessing(self.data    )
														self.final_hash()

							@staticmethod
							def      A_  (      a				:     bytes    )	->bytes:
														SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					b"\x80" + (b"\x00" * (63 - (len(__A    ) + 8) % 64))
														SCREAMING_SNAKE_CASE__     :				Any   =					struct.pack(">Q"							,	(len(__A    ) * 8)    )
														return data + padding + big_endian_integer

							def      A_  (      self				:     Dict    )	->None:
														# Convert into blocks of 64 bytes
														SCREAMING_SNAKE_CASE__     :				str   =					[
														    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__     :				int   =					list(struct.unpack(">16L"							,	__A    )    )
																					# 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__     :				Union[str, Any]   =					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__     :				int   =					(
																																			    self.ror(words[index - 15]							,	7    )
																																			    ^ self.ror(words[index - 15]							,	18    )
																																			    ^ (words[index - 15] >> 3)
																																			)
																																			SCREAMING_SNAKE_CASE__     :				int   =					(
																																			    self.ror(words[index - 2]							,	17    )
																																			    ^ self.ror(words[index - 2]							,	19    )
																																			    ^ (words[index - 2] >> 10)
																																			)

																																			SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					(
																																			    words[index - 16] + sa + words[index - 7] + sa
																																			) % 0X1_0000_0000

																												# Compression
																												SCREAMING_SNAKE_CASE__     :				Optional[int]   =					self.ror(__A							,	6    ) ^ self.ror(__A							,	11    ) ^ self.ror(__A							,	25    )
																												SCREAMING_SNAKE_CASE__     :				List[str]   =					(e & f) ^ ((~e & 0XFFFF_FFFF) & g)
																												SCREAMING_SNAKE_CASE__     :				List[str]   =					(
																												    h + sa + ch + self.round_constants[index] + words[index]
																												) % 0X1_0000_0000
																												SCREAMING_SNAKE_CASE__     :				List[str]   =					self.ror(__A							,	2    ) ^ self.ror(__A							,	13    ) ^ self.ror(__A							,	22    )
																												SCREAMING_SNAKE_CASE__     :				List[str]   =					(a & b) ^ (a & c) ^ (b & c)
																												SCREAMING_SNAKE_CASE__     :				List[Any]   =					(sa + maj) % 0X1_0000_0000

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

																					SCREAMING_SNAKE_CASE__     :				Tuple   =					[a, b, c, d, e, f, g, h]

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

														SCREAMING_SNAKE_CASE__     :				Optional[int]   =					"".join([hex(__A    )[2:].zfill(8    ) for value in self.hashes]    )






							def      A_  (      self				:     Optional[int]							,	a				:     int							,	a				:     int    )	->int:
														return 0XFFFF_FFFF & (value << (32 - rotations)) | (value >> rotations)







class    _a     (				unittest.TestCase							):






							"""simple docstring"""

							def      A_  (      self				:     Dict    )	->None:
														import hashlib

														SCREAMING_SNAKE_CASE__     :				Optional[int]   =					bytes("Test String"							,	"utf-8"    )
														self.assertEqual(SHAaaa(__A    ).hash							,	hashlib.shaaaa(__A    ).hexdigest()    )







def       UpperCAmelCase							(     ):





							'''simple docstring'''


							import doctest

							doctest.testmod()

							SCREAMING_SNAKE_CASE__     :				Dict   =					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__     :				Optional[Any]   =					parser.parse_args()

							SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					args.input_string

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

							print(SHAaaa(_lowercase     ).hash     )


if __name__ == "__main__":
				main()






# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__lowercase       :List[Any]       =  abspath(join(dirname(__file__), "src"))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action="ignore", category=FutureWarning)







def       UpperCAmelCase							(     _lowerCamelCase      :  int     ):





						'''simple docstring'''


						config.addinivalue_line(
						    "markers"			,   "is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"     )
						config.addinivalue_line(
						    "markers"			,   "is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"     )
						config.addinivalue_line("markers"			,   "is_pipeline_test: mark test to run only when pipelines are tested"     )
						config.addinivalue_line("markers"			,   "is_staging_test: mark test to run only in the staging environment"     )
						config.addinivalue_line("markers"			,   "accelerate_tests: mark test that require accelerate"     )
						config.addinivalue_line("markers"			,   "tool_tests: mark the tool tests that are run on their specific schedule"     )







def       UpperCAmelCase							(     _lowerCamelCase      :  str     ):





						'''simple docstring'''


						from transformers.testing_utils import pytest_addoption_shared

						pytest_addoption_shared(_lowerCamelCase     )







def       UpperCAmelCase							(     _lowerCamelCase      :  Tuple     ):





						'''simple docstring'''


						from transformers.testing_utils import pytest_terminal_summary_main

						SCREAMING_SNAKE_CASE__     :				List[str]   =					terminalreporter.config.getoption("--make-reports"     )
						if make_reports:
												pytest_terminal_summary_main(_lowerCamelCase			,   id=_lowerCamelCase     )







def       UpperCAmelCase							(     _lowerCamelCase      :  List[Any]			,   _lowerCamelCase      :  Dict     ):





						'''simple docstring'''


						if exitstatus == 5:
												SCREAMING_SNAKE_CASE__     :				List[str]   =					0


# Doctest custom flag to ignore output.
__lowercase       :Optional[Any]       =  doctest.register_optionflag("IGNORE_RESULT")

__lowercase       :Dict       =  doctest.OutputChecker



class    _a     (				lowercase__							):






							"""simple docstring"""

							def      A_  (      self				:     Dict							,	a				:     List[str]							,	a				:     Dict							,	a				:     int    )	->Optional[Any]:
													if IGNORE_RESULT & optionflags:
																			return True
													return OutputChecker.check_output(self							,	a							,	a							,	a    )







__lowercase       :Any       =  CustomOutputChecker
__lowercase       :Any       =  HfDoctestModule



__lowercase       :int       =  HfDocTestParser