


import argparse
import hashlib  # hashlib is only used inside the Test class
import struct
class 		__magic_name__						:





     '''simple docstring'''



     def __init__(					self:Union[str, Any]     ,		_a:List[str]   ):
       snake_case__						= data
       snake_case__						= [0X67_452_301, 0XEF_CDA_B89, 0X98_BAD_CFE, 0X10_325_476, 0XC3_D2E_1F0]

     @staticmethod
     def 	SCREAMING_SNAKE_CASE__						(					_a:Dict     ,		_a:List[str]   ):
       return ((n << b) | (n >> (32 - b))) & 0XFF_FFF_FFF

     def 	SCREAMING_SNAKE_CASE__						(					self:str   ):
       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 	SCREAMING_SNAKE_CASE__						(					self:Optional[Any]   ):
       return [
           self.padded_data[i : i + 64] for i in range(0     ,		len(self.padded_data   )     ,		64   )
       ]

     def 	SCREAMING_SNAKE_CASE__						(					self:Dict     ,		_a:Optional[Any]   ):
       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 	SCREAMING_SNAKE_CASE__						(					self:List[Any]   ):
       snake_case__						= self.padding()
       snake_case__						= self.split_blocks()
       for block in self.blocks:
         snake_case__						= self.expand_block(_a   )
         snake_case__				,				snake_case__				,				snake_case__				,				snake_case__				,				snake_case__						= self.h
         for i in range(0     ,		80   ):
           if 0 <= i < 20:
             snake_case__						= (b & c) | ((~b) & d)
             snake_case__						= 0X5A_827_999
           elif 20 <= i < 40:
             snake_case__						= b ^ c ^ d
             snake_case__						= 0X6E_D9E_BA1
           elif 40 <= i < 60:
             snake_case__						= (b & c) | (b & d) | (c & d)
             snake_case__						= 0X8F_1BB_CDC
           elif 60 <= i < 80:
             snake_case__						= b ^ c ^ d
             snake_case__						= 0XCA_62C_1D6
           snake_case__				,				snake_case__				,				snake_case__				,				snake_case__				,				snake_case__						= (
               self.rotate(_a     ,		5   ) + f + e + k + expanded_block[i] & 0XFF_FFF_FFF,
               a,
               self.rotate(_a     ,		30   ),
               c,
               d,
           )
         snake_case__						= (
             self.h[0] + a & 0XFF_FFF_FFF,
             self.h[1] + b & 0XFF_FFF_FFF,
             self.h[2] + c & 0XFF_FFF_FFF,
             self.h[3] + d & 0XFF_FFF_FFF,
             self.h[4] + e & 0XFF_FFF_FFF,
         )
       return ("{:08x}" * 5).format(*self.h   )







def SCREAMING_SNAKE_CASE	(			)    ->				Optional[Any]:
  snake_case__						= B'''Test String'''
  assert SHAaHash(__lowerCAmelCase				).final_hash() == hashlib.shaa(__lowerCAmelCase				).hexdigest()  # noqa: S324







def SCREAMING_SNAKE_CASE	(			)    ->				Union[str, Any]:
  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()





import pytest

from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs







@pytest.mark.parametrize(
    '''kwargs, expected'''							,   [
        ({'''num_shards''': 0, '''max_num_jobs''': 1}, []),
        ({'''num_shards''': 10, '''max_num_jobs''': 1}, [range(10				)]),
        ({'''num_shards''': 10, '''max_num_jobs''': 10}, [range(__lowerCAmelCase							,   i + 1				) for i in range(10				)]),
        ({'''num_shards''': 1, '''max_num_jobs''': 10}, [range(1				)]),
        ({'''num_shards''': 10, '''max_num_jobs''': 3}, [range(0							,   4				), range(4							,   7				), range(7							,   10				)]),
        ({'''num_shards''': 3, '''max_num_jobs''': 10}, [range(0							,   1				), range(1							,   2				), range(2							,   3				)]),
    ]							,   )
def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase							,   __lowerCAmelCase				)    ->				Optional[int]:
  snake_case__						= _distribute_shards(**__lowerCAmelCase				)
  assert out == expected







@pytest.mark.parametrize(
    '''gen_kwargs, max_num_jobs, expected'''							,   [
        ({'''foo''': 0}, 10, [{'''foo''': 0}]),
        ({'''shards''': [0, 1, 2, 3]}, 1, [{'''shards''': [0, 1, 2, 3]}]),
        ({'''shards''': [0, 1, 2, 3]}, 4, [{'''shards''': [0]}, {'''shards''': [1]}, {'''shards''': [2]}, {'''shards''': [3]}]),
        ({'''shards''': [0, 1]}, 4, [{'''shards''': [0]}, {'''shards''': [1]}]),
        ({'''shards''': [0, 1, 2, 3]}, 2, [{'''shards''': [0, 1]}, {'''shards''': [2, 3]}]),
    ]							,   )
def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase							,   __lowerCAmelCase							,   __lowerCAmelCase				)    ->				Dict:
  snake_case__						= _split_gen_kwargs(__lowerCAmelCase							,   __lowerCAmelCase				)
  assert out == expected







@pytest.mark.parametrize(
    '''gen_kwargs, expected'''							,   [
        ({'''foo''': 0}, 1),
        ({'''shards''': [0]}, 1),
        ({'''shards''': [0, 1, 2, 3]}, 4),
        ({'''shards''': [0, 1, 2, 3], '''foo''': 0}, 4),
        ({'''shards''': [0, 1, 2, 3], '''other''': (0, 1)}, 4),
        ({'''shards''': [0, 1, 2, 3], '''shards2''': [0, 1]}, RuntimeError),
    ]							,   )
def SCREAMING_SNAKE_CASE	(			__lowerCAmelCase							,   __lowerCAmelCase				)    ->				List[Any]:
  if expected is RuntimeError:
    with pytest.raises(__lowerCAmelCase				):
      _number_of_shards_in_gen_kwargs(__lowerCAmelCase				)
  else:
    snake_case__						= _number_of_shards_in_gen_kwargs(__lowerCAmelCase				)
    assert out == expected

