


'''simple docstring'''




from collections.abc import Generator
from math import sin





def       a_   (					lowerCamelCase      :	Dict							):


   if len(_lowercase							) != 32:
      raise ValueError('Input must be of length 32'							)

   lowerCAmelCase	=     b''
   for i in [3, 2, 1, 0]:
      little_endian += string_aa[8 * i : 8 * i + 8]
   return little_endian





def       a_   (					lowerCamelCase      :	Optional[int]							):


   if i < 0:
      raise ValueError('Input must be non-negative'							)

   lowerCAmelCase	=     format(_lowercase      ,					'08x'							)[-8:]
   lowerCAmelCase	=     b''
   for i in [3, 2, 1, 0]:
      little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('utf-8'							)
   return little_endian_hex





def       a_   (					lowerCamelCase      :	List[Any]							):
   lowerCAmelCase	=     b''
   for char in message:
      bit_string += format(_lowercase      ,					'08b'							).encode('utf-8'							)
   lowerCAmelCase	=     format(len(_lowercase							)      ,					'064b'							).encode('utf-8'							)

   # Pad bit_string to a multiple of 512 chars
   bit_string += b"1"
   while len(_lowercase							) % 512 != 448:
      bit_string += b"0"
   bit_string += to_little_endian(start_len[32:]							) + to_little_endian(start_len[:32]							)

   return bit_string





def       a_   (					lowerCamelCase      :	int							):


   if len(_lowercase							) % 512 != 0:
      raise ValueError('Input must have length that\'s a multiple of 512'							)

   for pos in range(0      ,					len(_lowercase							)      ,					512							):
      lowerCAmelCase	=     bit_string[pos : pos + 512]
      lowerCAmelCase	=     []
      for i in range(0      ,					512      ,					32							):
         block_words.append(int(to_little_endian(block[i : i + 32]							)      ,					2							)							)
      yield block_words





def       a_   (					lowerCamelCase      :	Union[str, Any]							):


   if i < 0:
      raise ValueError('Input must be non-negative'							)

   lowerCAmelCase	=     format(_lowercase      ,					'032b'							)
   lowerCAmelCase	=     ''
   for c in i_str:
      new_str += "1" if c == "0" else "0"
   return int(_lowercase      ,					2							)





def       a_   (					lowerCamelCase      :	List[Any]      ,					lowerCamelCase      :	List[str]							):
   return (a + b) % 2**32





def       a_   (					lowerCamelCase      :	List[str]      ,					lowerCamelCase      :	Optional[Any]							):


   if i < 0:
      raise ValueError('Input must be non-negative'							)
   if shift < 0:
      raise ValueError('Shift must be non-negative'							)
   return ((i << shift) ^ (i >> (32 - shift))) % 2**32





def       a_   (					lowerCamelCase      :	List[Any]							):
   lowerCAmelCase	=     preprocess(_lowercase							)

   lowerCAmelCase	=     [int(2**32 * abs(sin(i + 1							)							)							) for i in range(64							)]

   # Starting states
   lowerCAmelCase	=     0x67_452_301
   lowerCAmelCase	=     0xEF_CDA_B89
   lowerCAmelCase	=     0x98_BAD_CFE
   lowerCAmelCase	=     0x10_325_476

   lowerCAmelCase	=     [
       7,
       12,
       17,
       22,
       7,
       12,
       17,
       22,
       7,
       12,
       17,
       22,
       7,
       12,
       17,
       22,
       5,
       9,
       14,
       20,
       5,
       9,
       14,
       20,
       5,
       9,
       14,
       20,
       5,
       9,
       14,
       20,
       4,
       11,
       16,
       23,
       4,
       11,
       16,
       23,
       4,
       11,
       16,
       23,
       4,
       11,
       16,
       23,
       6,
       10,
       15,
       21,
       6,
       10,
       15,
       21,
       6,
       10,
       15,
       21,
       6,
       10,
       15,
       21,
   ]

   # Process bit string in chunks, each with 16 32-char words
   for block_words in get_block_words(_lowercase							):
      lowerCAmelCase	=     aa
      lowerCAmelCase	=     ba
      lowerCAmelCase	=     ca
      lowerCAmelCase	=     da

      # Hash current chunk
      for i in range(64							):
         if i <= 15:
            # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
            lowerCAmelCase	=     d ^ (b & (c ^ d))
            lowerCAmelCase	=     i
         elif i <= 31:
            # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
            lowerCAmelCase	=     c ^ (d & (b ^ c))
            lowerCAmelCase	=     (5 * i + 1) % 16
         elif i <= 47:
            lowerCAmelCase	=     b ^ c ^ d
            lowerCAmelCase	=     (3 * i + 5) % 16
         else:
            lowerCAmelCase	=     c ^ (b | not_aa(_lowercase							))
            lowerCAmelCase	=     (7 * i) % 16
         lowerCAmelCase	=     (f + a + added_consts[i] + block_words[g]) % 2**32
         lowerCAmelCase	=     d
         lowerCAmelCase	=     c
         lowerCAmelCase	=     b
         lowerCAmelCase	=     sum_aa(_lowercase      ,					left_rotate_aa(_lowercase      ,					shift_amounts[i]							)							)

      # Add hashed chunk to running total
      lowerCAmelCase	=     sum_aa(_lowercase      ,					_lowercase							)
      lowerCAmelCase	=     sum_aa(_lowercase      ,					_lowercase							)
      lowerCAmelCase	=     sum_aa(_lowercase      ,					_lowercase							)
      lowerCAmelCase	=     sum_aa(_lowercase      ,					_lowercase							)

   lowerCAmelCase	=     reformat_hex(_lowercase							) + reformat_hex(_lowercase							) + reformat_hex(_lowercase							) + reformat_hex(_lowercase							)
   return digest


if __name__ == "__main__":
       import doctest

       doctest.testmod()









from collections.abc import Generator
from math import sin






def 		_A		(		_lowercase )					-> bytes:


     """simple docstring"""


     if len(_lowercase ) != 32:
          raise ValueError('Input must be of length 32' )

     __UpperCamelCase =			B''
     for i in [3, 2, 1, 0]:
          little_endian += string_aa[8 * i : 8 * i + 8]
     return little_endian






def 		_A		(		_lowercase )					-> bytes:


     """simple docstring"""


     if i < 0:
          raise ValueError('Input must be non-negative' )

     __UpperCamelCase =			format(_lowercase					,  '08x' )[-8:]
     __UpperCamelCase =			B''
     for i in [3, 2, 1, 0]:
          little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('utf-8' )
     return little_endian_hex






def 		_A		(		_lowercase )					-> bytes:


     """simple docstring"""


     __UpperCamelCase =			B''
     for char in message:
          bit_string += format(_lowercase					,  '08b' ).encode('utf-8' )
     __UpperCamelCase =			format(len(_lowercase )					,  '064b' ).encode('utf-8' )

     # Pad bit_string to a multiple of 512 chars
     bit_string += b"1"
     while len(_lowercase ) % 5_12 != 4_48:
          bit_string += b"0"
     bit_string += to_little_endian(start_len[32:] ) + to_little_endian(start_len[:32] )

     return bit_string






def 		_A		(		_lowercase )					-> Generator[list[int], None, None]:


     """simple docstring"""


     if len(_lowercase ) % 5_12 != 0:
          raise ValueError('Input must have length that\'s a multiple of 512' )

     for pos in range(0					,  len(_lowercase )					,  5_12 ):
          __UpperCamelCase =			bit_string[pos : pos + 5_12]
          __UpperCamelCase =			[]
          for i in range(0					,  5_12					,  32 ):
               block_words.append(int(to_little_endian(block[i : i + 32] )					,  2 ) )
          yield block_words






def 		_A		(		_lowercase )					-> int:


     """simple docstring"""


     if i < 0:
          raise ValueError('Input must be non-negative' )

     __UpperCamelCase =			format(_lowercase					,  '032b' )
     __UpperCamelCase =			''
     for c in i_str:
          new_str += "1" if c == "0" else "0"
     return int(_lowercase					,  2 )






def 		_A		(		_lowercase					,  _lowercase )					-> int:


     """simple docstring"""


     return (a + b) % 2**32






def 		_A		(		_lowercase					,  _lowercase )					-> int:


     """simple docstring"""


     if i < 0:
          raise ValueError('Input must be non-negative' )
     if shift < 0:
          raise ValueError('Shift must be non-negative' )
     return ((i << shift) ^ (i >> (32 - shift))) % 2**32






def 		_A		(		_lowercase )					-> bytes:


     """simple docstring"""


     __UpperCamelCase =			preprocess(_lowercase )

     __UpperCamelCase =			[int(2**32 * abs(sin(i + 1 ) ) ) for i in range(64 )]

     # Starting states
     __UpperCamelCase =			0X67_45_23_01
     __UpperCamelCase =			0Xef_cd_ab_89
     __UpperCamelCase =			0X98_ba_dc_fe
     __UpperCamelCase =			0X10_32_54_76

     __UpperCamelCase =			[
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
     ]

     # Process bit string in chunks, each with 16 32-char words
     for block_words in get_block_words(_lowercase ):
          __UpperCamelCase =			aa
          __UpperCamelCase =			ba
          __UpperCamelCase =			ca
          __UpperCamelCase =			da

          # Hash current chunk
          for i in range(64 ):
               if i <= 15:
                    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
                    __UpperCamelCase =			d ^ (b & (c ^ d))
                    __UpperCamelCase =			i
               elif i <= 31:
                    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
                    __UpperCamelCase =			c ^ (d & (b ^ c))
                    __UpperCamelCase =			(5 * i + 1) % 16
               elif i <= 47:
                    __UpperCamelCase =			b ^ c ^ d
                    __UpperCamelCase =			(3 * i + 5) % 16
               else:
                    __UpperCamelCase =			c ^ (b | not_aa(_lowercase ))
                    __UpperCamelCase =			(7 * i) % 16
               __UpperCamelCase =			(f + a + added_consts[i] + block_words[g]) % 2**32
               __UpperCamelCase =			d
               __UpperCamelCase =			c
               __UpperCamelCase =			b
               __UpperCamelCase =			sum_aa(_lowercase					,  left_rotate_aa(_lowercase					,  shift_amounts[i] ) )

          # Add hashed chunk to running total
          __UpperCamelCase =			sum_aa(_lowercase					,  _lowercase )
          __UpperCamelCase =			sum_aa(_lowercase					,  _lowercase )
          __UpperCamelCase =			sum_aa(_lowercase					,  _lowercase )
          __UpperCamelCase =			sum_aa(_lowercase					,  _lowercase )

     __UpperCamelCase =			reformat_hex(_lowercase ) + reformat_hex(_lowercase ) + reformat_hex(_lowercase ) + reformat_hex(_lowercase )
     return digest


if __name__ == "__main__":
    import doctest

    doctest.testmod()


