





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





class  lowerCAmelCase							:







  def __init__(      self  :int   ,							_lowercase  :List[Any] ):






     '''simple docstring'''





     lowercase__			       =  data
     lowercase__			       =  [0X67452301, 0XEFCDAB89, 0X98BADCFE, 0X10325476, 0XC3D2E1F0]







  @staticmethod
  def   UpperCAmelCase					(      _lowercase  :Optional[Any]   ,							_lowercase  :Optional[Any] ):






     '''simple docstring'''





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







  def   UpperCAmelCase					(      self  :Union[str, Any] ):






     '''simple docstring'''





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







  def   UpperCAmelCase					(      self  :int ):






     '''simple docstring'''





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







  def   UpperCAmelCase					(      self  :Optional[int]   ,							_lowercase  :str ):






     '''simple docstring'''





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







  def   UpperCAmelCase					(      self  :List[Any] ):






     '''simple docstring'''





     lowercase__			       =  self.padding()
     lowercase__			       =  self.split_blocks()
     for block in self.blocks:
        lowercase__			       =  self.expand_block(_lowercase )
        lowercase__       ,							lowercase__       ,							lowercase__       ,							lowercase__       ,							lowercase__			       =  self.h
        for i in range(0   ,							80 ):
           if 0 <= i < 20:
              lowercase__			       =  (b & c) | ((~b) & d)
              lowercase__			       =  0X5A827999
           elif 20 <= i < 40:
              lowercase__			       =  b ^ c ^ d
              lowercase__			       =  0X6ED9EBA1
           elif 40 <= i < 60:
              lowercase__			       =  (b & c) | (b & d) | (c & d)
              lowercase__			       =  0X8F1BBCDC
           elif 60 <= i < 80:
              lowercase__			       =  b ^ c ^ d
              lowercase__			       =  0XCA62C1D6
           lowercase__       ,							lowercase__       ,							lowercase__       ,							lowercase__       ,							lowercase__			       =  (
               self.rotate(_lowercase   ,							5 ) + f + e + k + expanded_block[i] & 0XFFFFFFFF,
               a,
               self.rotate(_lowercase   ,							30 ),
               c,
               d,
           )
        lowercase__			       =  (
            self.h[0] + a & 0XFFFFFFFF,
            self.h[1] + b & 0XFFFFFFFF,
            self.h[2] + c & 0XFFFFFFFF,
            self.h[3] + d & 0XFFFFFFFF,
            self.h[4] + e & 0XFFFFFFFF,
        )
     return ("{:08x}" * 5).format(*self.h )


def _A       (   ):
   lowercase__			       =  B"Test String"
   assert SHAaHash(__magic_name__	).final_hash() == hashlib.shaa(__magic_name__	).hexdigest()  # noqa: S324


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


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

  doctest.testmod()













def _A       (   __magic_name__	):
   lowercase__			       =  ""
   for ch in key:
      if ch == " " or ch not in key_no_dups and ch.isalpha():
         key_no_dups += ch
   return key_no_dups


def _A       (   __magic_name__	):
   lowercase__			       =  [chr(i + 65	) for i in range(26	)]
   # Remove duplicate characters from key
   lowercase__			       =  remove_duplicates(key.upper()	)
   lowercase__			       =  len(__magic_name__	)
   # First fill cipher with key characters
   lowercase__			       =  {alphabet[i]: char for i, char in enumerate(__magic_name__	)}
   # Then map remaining characters in alphabet to
   # the alphabet from the beginning
   for i in range(len(__magic_name__	)  , 26	):
      lowercase__			       =  alphabet[i - offset]
      # Ensure we are not mapping letters to letters previously mapped
      while char in key:
         offset -= 1
         lowercase__			       =  alphabet[i - offset]
      lowercase__			       =  char
   return cipher_alphabet


def _A       (   __magic_name__  , __magic_name__	):
   return "".join(cipher_map.get(__magic_name__  , __magic_name__	) for ch in message.upper()	)


def _A       (   __magic_name__  , __magic_name__	):
   lowercase__			       =  {v: k for k, v in cipher_map.items()}
   return "".join(rev_cipher_map.get(__magic_name__  , __magic_name__	) for ch in message.upper()	)


def _A       (   ):
   lowercase__			       =  input("Enter message to encode or decode: "	).strip()
   lowercase__			       =  input("Enter keyword: "	).strip()
   lowercase__			       =  input("Encipher or decipher? E/D:"	).strip()[0].lower()
   try:
      lowercase__			       =  {"e": encipher, "d": decipher}[option]
   except KeyError:
      raise KeyError("invalid input option"	)
   lowercase__			       =  create_cipher_map(__magic_name__	)
   print(func(__magic_name__  , __magic_name__	)	)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()






