
'''simple docstring'''







import argparse
import struct
import unittest







class UpperCAmelCase__      :





  """simple docstring"""

  def __init__(						self :	Dict				,_a :	bytes			):


     '''simple docstring'''






     _a							:      Optional[int]     =  data

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

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

     _a							:      Union[str, Any]     =  self.preprocessing(self.data			)
     self.final_hash()


  @staticmethod
  def     __lowercase						(						_a :	bytes			):


     '''simple docstring'''






     _a							:      Any     =  B'\x80' + (B'\x00' * (63 - (len(__A			) + 8) % 64))
     _a							:      Optional[int]     =  struct.pack('>Q'				,(len(__A			) * 8)			)
     return data + padding + big_endian_integer


  def     __lowercase						(						self :	Dict			):


     '''simple docstring'''






     _a							:      Tuple     =  [
         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
        _a							:      List[Any]     =  list(struct.unpack('>16L'				,__A			)			)
        # add 48 0-ed integers
        words += [0] * 48

        _a,    _a,    _a,    _a,    _a,    _a,    _a,    _a							:      Optional[int]     =  self.hashes

        for index in range(0				,64			):
           if index > 15:
              # modify the zero-ed indexes at the end of the array
              _a							:      Dict     =  (
                  self.ror(words[index - 15]				,7			)
                  ^ self.ror(words[index - 15]				,18			)
                  ^ (words[index - 15] >> 3)
              )
              _a							:      List[str]     =  (
                  self.ror(words[index - 2]				,17			)
                  ^ self.ror(words[index - 2]				,19			)
                  ^ (words[index - 2] >> 10)
              )

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

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

           _a,    _a,    _a,    _a,    _a,    _a,    _a,    _a							:      List[Any]     =  (
               g,
               f,
               e,
               ((d + tempa) % 0X1_0000_0000),
               c,
               b,
               a,
               ((tempa + tempa) % 0X1_0000_0000),
           )

        _a							:      str     =  [a, b, c, d, e, f, g, h]

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

     _a							:      int     =  ''.join([hex(__A			)[2:].zfill(8			) for value in self.hashes]			)


  def     __lowercase						(						self :	Any				,_a :	int				,_a :	int			):


     '''simple docstring'''






     return 0Xffff_ffff & (value << (32 - rotations)) | (value >> rotations)







class UpperCAmelCase__      (					unittest.TestCase      ):





  """simple docstring"""

  def     __lowercase						(						self :	Tuple			):


     '''simple docstring'''






     import hashlib

     _a							:      int     =  bytes('Test String'				,'utf-8'			)
     self.assertEqual(SHAaaa(__A			).hash				,hashlib.shaaaa(__A			).hexdigest()			)





def    UpperCAmelCase_						():






   """simple docstring"""

   import doctest

   doctest.testmod()

   _a							:      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'					)

   _a							:      str     =  parser.parse_args()

   _a							:      List[Any]     =  args.input_string

   # hash input should be a bytestring
   if args.input_file:
      with open(args.input_file					,      'rb'					) as f:
         _a							:      Dict     =  f.read()
   else:
      _a							:      List[Any]     =  bytes(UpperCamelCase__					,      'utf-8'					)

   print(SHAaaa(UpperCamelCase__					).hash					)


if __name__ == "__main__":
  main()










import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Value
from .base import TaskTemplate




@dataclass(frozen=UpperCamelCase__     )
class 	UpperCamelCase_							(  UpperCamelCase__     ):
							# `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
							lowerCamelCase_							     =       field(default="text-classification"					,	metadata={"include_in_asdict_even_if_is_default": True}     )
							lowerCamelCase_							     =       Features({"text": Value("string"     )}     )
							lowerCamelCase_							     =       Features({"labels": ClassLabel}     )
							lowerCamelCase_							     =       "text"
							lowerCamelCase_							     =       "labels"


							def   _snake_case	(				self     :Any				,					__A     :Dict		) -> Optional[Any]:



									"""simple docstring"""



									if self.label_column not in features:
											raise ValueError(f'''Column {self.label_column} is not present in features.'''		)
									if not isinstance(features[self.label_column]				,					__A		):
											raise ValueError(f'''Column {self.label_column} is not a ClassLabel.'''		)
									SCREAMING_SNAKE_CASE__								=   copy.deepcopy(self		)
									SCREAMING_SNAKE_CASE__								=   self.label_schema.copy()
									SCREAMING_SNAKE_CASE__								=   features[self.label_column]
									SCREAMING_SNAKE_CASE__								=   label_schema
									return task_template


							@property
							def   _snake_case	(				self     :str		) -> Dict[str, str]:



									"""simple docstring"""



									return {
									    self.text_column: "text",
									    self.label_column: "labels",
									}