G2A Many GEOs
SHARE
TWEET

ceasar

a guest Apr 10th, 2020 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import argparse
  2.  
  3. parser = argparse.ArgumentParser(description="Vigenere cipher tool")
  4.  
  5. parser.add_argument('-e', '--encrypt', action='store_true', help='Encrypt ASCII message')
  6. parser.add_argument('-d', '--decrypt', action='store_true' , help = "Decrypt ASCII message")
  7.  
  8. args = parser.parse_args()
  9.  
  10. def encrypt(plaintext, shift):
  11.     ciphertext = ''
  12.     for i in range(len(plaintext)):
  13.         ciphertext += chr(ord(plaintext[i]) + shift % 26)
  14.     print(ciphertext)
  15.  
  16. def decrypt(ciphertext, shift):
  17.     plaintext = ''
  18.     for i in range(len(ciphertext)):
  19.         plaintext += chr(ord(ciphertext[i]) - shift % 26)
  20.     print(plaintext)
  21.  
  22. def main():
  23.     if args.encrypt:
  24.         plaintext = raw_input('Enter plaintext: ').upper()
  25.         shift = int(raw_input('Enter shift: '))
  26.         encrypt(plaintext, shift)
  27.     if args.decrypt:
  28.         ciphertext = raw_input('Enter ciphertext: ').upper()
  29.         shift = int(raw_input('Enter shift: '))
  30.         decrypt(ciphertext, shift)
  31.  
  32. if __name__ == "__main__":
  33.     main()
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top