





'''simple docstring'''

import argparse
import struct
import unittest


class 					a_     :

    '''simple docstring'''


    def __init__(		self ,		A       )		->   None:
        _SCREAMING_SNAKE_CASE									=			data

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

        # Initialize round constants
        _SCREAMING_SNAKE_CASE									=			[
            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									=			self.preprocessing(self.data       )
        self.final_hash()


    @staticmethod
    def 			snake_case_(		A       )		->   bytes:
        _SCREAMING_SNAKE_CASE									=			b"""\x80""" + (b"""\x00""" * (63 - (len(A       ) + 8) % 64))
        _SCREAMING_SNAKE_CASE									=			struct.pack(""">Q""" ,		(len(A       ) * 8)       )
        return data + padding + big_endian_integer


    def 			snake_case_(		self       )		->   None:
        # Convert into blocks of 64 bytes
        _SCREAMING_SNAKE_CASE									=			[
            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									=			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									=			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									=			(
                        self.ror(words[index - 15] ,		7       )
                        ^ self.ror(words[index - 15] ,		18       )
                        ^ (words[index - 15] >> 3)
                    )
                    _SCREAMING_SNAKE_CASE									=			(
                        self.ror(words[index - 2] ,		17       )
                        ^ self.ror(words[index - 2] ,		19       )
                        ^ (words[index - 2] >> 10)
                    )

                    _SCREAMING_SNAKE_CASE									=			(
                        words[index - 16] + sa + words[index - 7] + sa
                    ) % 0X1_0000_0000

                # Compression
                _SCREAMING_SNAKE_CASE									=			self.ror(A ,		6       ) ^ self.ror(A ,		11       ) ^ self.ror(A ,		25       )
                _SCREAMING_SNAKE_CASE									=			(e & f) ^ ((~e & 0Xffff_ffff) & g)
                _SCREAMING_SNAKE_CASE									=			(
                    h + sa + ch + self.round_constants[index] + words[index]
                ) % 0X1_0000_0000
                _SCREAMING_SNAKE_CASE									=			self.ror(A ,		2       ) ^ self.ror(A ,		13       ) ^ self.ror(A ,		22       )
                _SCREAMING_SNAKE_CASE									=			(a & b) ^ (a & c) ^ (b & c)
                _SCREAMING_SNAKE_CASE									=			(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									=			(
                    g,
                    f,
                    e,
                    ((d + tempa) % 0X1_0000_0000),
                    c,
                    b,
                    a,
                    ((tempa + tempa) % 0X1_0000_0000),
                )

            _SCREAMING_SNAKE_CASE									=			[a, b, c, d, e, f, g, h]

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

        _SCREAMING_SNAKE_CASE									=			"""""".join([hex(A       )[2:].zfill(8       ) for value in self.hashes]       )





    def 			snake_case_(		self ,		A ,		A       )		->   int:
        return 0Xffff_ffff & (value << (32 - rotations)) | (value >> rotations)




class 					a_     (				unittest.TestCase       ):

    '''simple docstring'''


    def 			snake_case_(		self       )		->   None:
        import hashlib

        _SCREAMING_SNAKE_CASE									=			bytes("""Test String""" ,		"""utf-8"""       )
        self.assertEqual(SHAaaa(A       ).hash ,		hashlib.shaaaa(A       ).hexdigest()       )





def lowerCamelCase						(     )						->None:
    import doctest

    doctest.testmod()

    _SCREAMING_SNAKE_CASE									=			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									=			parser.parse_args()

    _SCREAMING_SNAKE_CASE									=			args.input_string

    # hash input should be a bytestring
    if args.input_file:
        with open(args.input_file					,       """rb"""    ) as f:
            _SCREAMING_SNAKE_CASE									=			f.read()
    else:
        _SCREAMING_SNAKE_CASE									=			bytes(__lowerCamelCase					,       """utf-8"""    )

    print(SHAaaa(__lowerCamelCase    ).hash    )


if __name__ == "__main__":
      main()










'''simple docstring'''

from typing import TYPE_CHECKING

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


lowercase_					= {"""configuration_mbart""": ["""MBART_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MBartConfig""", """MBartOnnxConfig"""]}

try:
      if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_					= ["""MBartTokenizer"""]

try:
      if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_					= ["""MBartTokenizerFast"""]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_					= [
          """MBART_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """MBartForCausalLM""",
          """MBartForConditionalGeneration""",
          """MBartForQuestionAnswering""",
          """MBartForSequenceClassification""",
          """MBartModel""",
          """MBartPreTrainedModel""",
      ]

try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_					= [
          """TFMBartForConditionalGeneration""",
          """TFMBartModel""",
          """TFMBartPreTrainedModel""",
      ]

try:
      if not is_flax_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase_					= [
          """FlaxMBartForConditionalGeneration""",
          """FlaxMBartForQuestionAnswering""",
          """FlaxMBartForSequenceClassification""",
          """FlaxMBartModel""",
          """FlaxMBartPreTrainedModel""",
      ]


if TYPE_CHECKING:
      from .configuration_mbart import MBART_PRETRAINED_CONFIG_ARCHIVE_MAP, MBartConfig, MBartOnnxConfig

      try:
            if not is_sentencepiece_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_mbart import MBartTokenizer

      try:
            if not is_tokenizers_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_mbart_fast import MBartTokenizerFast

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_mbart import (
                MBART_PRETRAINED_MODEL_ARCHIVE_LIST,
                MBartForCausalLM,
                MBartForConditionalGeneration,
                MBartForQuestionAnswering,
                MBartForSequenceClassification,
                MBartModel,
                MBartPreTrainedModel,
            )

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_mbart import TFMBartForConditionalGeneration, TFMBartModel, TFMBartPreTrainedModel

      try:
            if not is_flax_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_flax_mbart import (
                FlaxMBartForConditionalGeneration,
                FlaxMBartForQuestionAnswering,
                FlaxMBartForSequenceClassification,
                FlaxMBartModel,
                FlaxMBartPreTrainedModel,
            )

else:
      import sys

      lowercase_					= _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



