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



class      lowerCAmelCase_			:



				"""simple docstring"""

				def __init__( self						,			lowerCAmelCase			):






										"""simple docstring"""

										snake_case	    =	data
										snake_case	    =	[0x6_7_4_5_2_3_0_1, 0xE_F_C_D_A_B_8_9, 0x9_8_B_A_D_C_F_E, 0x1_0_3_2_5_4_7_6, 0xC_3_D_2_E_1_F_0]

				@staticmethod
				def 						snake_case       ( lowerCAmelCase						,			lowerCAmelCase			):






										"""simple docstring"""

										return ((n << b) | (n >> (32 - b))) & 0xF_F_F_F_F_F_F_F

				def 						snake_case       ( self			):






										"""simple docstring"""

										snake_case	    =	b"\x80" + b"\x00" * (63 - (len(self.data			) + 8) % 64)
										snake_case	    =	self.data + padding + struct.pack('>Q'						,			8 * len(self.data			)			)
										return padded_data

				def 						snake_case       ( self			):






										"""simple docstring"""

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

				def 						snake_case       ( self						,			lowerCAmelCase			):






										"""simple docstring"""

										snake_case	    =	list(struct.unpack('>16L'						,			A_			)			) + [0] * 64
										for i in range(16						,			80			):
																snake_case	    =	self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16])						,			1			)
										return w

				def 						snake_case       ( self			):






										"""simple docstring"""

										snake_case	    =	self.padding()
										snake_case	    =	self.split_blocks()
										for block in self.blocks:
																snake_case	    =	self.expand_block(A_			)
																snake_case	    =	self.h
																for i in range(0						,			80			):
																						if 0 <= i < 20:
																												snake_case	    =	(b & c) | ((~b) & d)
																												snake_case	    =	0x5_A_8_2_7_9_9_9
																						elif 20 <= i < 40:
																												snake_case	    =	b ^ c ^ d
																												snake_case	    =	0x6_E_D_9_E_B_A_1
																						elif 40 <= i < 60:
																												snake_case	    =	(b & c) | (b & d) | (c & d)
																												snake_case	    =	0x8_F_1_B_B_C_D_C
																						elif 60 <= i < 80:
																												snake_case	    =	b ^ c ^ d
																												snake_case	    =	0xC_A_6_2_C_1_D_6
																						snake_case	    =	(
																						    self.rotate(A_						,			5			) + f + e + k + expanded_block[i] & 0xF_F_F_F_F_F_F_F,
																						    a,
																						    self.rotate(A_						,			30			),
																						    c,
																						    d,
																						)
																snake_case	    =	(
																    self.h[0] + a & 0xF_F_F_F_F_F_F_F,
																    self.h[1] + b & 0xF_F_F_F_F_F_F_F,
																    self.h[2] + c & 0xF_F_F_F_F_F_F_F,
																    self.h[3] + d & 0xF_F_F_F_F_F_F_F,
																    self.h[4] + e & 0xF_F_F_F_F_F_F_F,
																)
										return ("{:08x}" * 5).format(*self.h			)





def       lowerCAmelCase__			(	)    -> Any:





						"""simple docstring"""






						snake_case	    =	b"Test String"
						assert SHAaHash(_lowerCAmelCase    ).final_hash() == hashlib.shaa(_lowerCAmelCase    ).hexdigest()  # noqa: S324





def       lowerCAmelCase__			(	)    -> Any:





						"""simple docstring"""






						snake_case	    =	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'    )
						snake_case	    =	parser.parse_args()
						snake_case	    =	args.input_string
						# In any case hash input should be a bytestring
						if args.input_file:
												with open(args.input_file       ,	'rb'    ) as f:
																		snake_case	    =	f.read()
						else:
												snake_case	    =	bytes(_lowerCAmelCase       ,	'utf-8'    )
						print(SHAaHash(_lowerCAmelCase    ).final_hash()    )


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

					doctest.testmod()









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCamelCase       :     Any   =     {
    """configuration_electra""": ["""ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ElectraConfig""", """ElectraOnnxConfig"""],
    """tokenization_electra""": ["""ElectraTokenizer"""],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase       :     Dict   =     ["""ElectraTokenizerFast"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase       :     Tuple   =     [
        """ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """ElectraForCausalLM""",
        """ElectraForMaskedLM""",
        """ElectraForMultipleChoice""",
        """ElectraForPreTraining""",
        """ElectraForQuestionAnswering""",
        """ElectraForSequenceClassification""",
        """ElectraForTokenClassification""",
        """ElectraModel""",
        """ElectraPreTrainedModel""",
        """load_tf_weights_in_electra""",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase       :     List[Any]   =     [
        """TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """TFElectraForMaskedLM""",
        """TFElectraForMultipleChoice""",
        """TFElectraForPreTraining""",
        """TFElectraForQuestionAnswering""",
        """TFElectraForSequenceClassification""",
        """TFElectraForTokenClassification""",
        """TFElectraModel""",
        """TFElectraPreTrainedModel""",
    ]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase       :     List[str]   =     [
        """FlaxElectraForCausalLM""",
        """FlaxElectraForMaskedLM""",
        """FlaxElectraForMultipleChoice""",
        """FlaxElectraForPreTraining""",
        """FlaxElectraForQuestionAnswering""",
        """FlaxElectraForSequenceClassification""",
        """FlaxElectraForTokenClassification""",
        """FlaxElectraModel""",
        """FlaxElectraPreTrainedModel""",
    ]


if TYPE_CHECKING:
    from .configuration_electra import ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, ElectraConfig, ElectraOnnxConfig
    from .tokenization_electra import ElectraTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_electra_fast import ElectraTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_electra import (
            ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
            ElectraForCausalLM,
            ElectraForMaskedLM,
            ElectraForMultipleChoice,
            ElectraForPreTraining,
            ElectraForQuestionAnswering,
            ElectraForSequenceClassification,
            ElectraForTokenClassification,
            ElectraModel,
            ElectraPreTrainedModel,
            load_tf_weights_in_electra,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_electra import (
            TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFElectraForMaskedLM,
            TFElectraForMultipleChoice,
            TFElectraForPreTraining,
            TFElectraForQuestionAnswering,
            TFElectraForSequenceClassification,
            TFElectraForTokenClassification,
            TFElectraModel,
            TFElectraPreTrainedModel,
        )

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_electra import (
            FlaxElectraForCausalLM,
            FlaxElectraForMaskedLM,
            FlaxElectraForMultipleChoice,
            FlaxElectraForPreTraining,
            FlaxElectraForQuestionAnswering,
            FlaxElectraForSequenceClassification,
            FlaxElectraForTokenClassification,
            FlaxElectraModel,
            FlaxElectraPreTrainedModel,
        )

else:
    import sys

    __lowerCamelCase       :     Any   =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
