Cryptography: Caesar Cipher Python 3

Give a thumbs up 👍🏻 if my code was useful to you. Showing compilation and execution of my code in Python 3, which is capable of Encrypting, Decrypting, B...

Arvin Babaei57 views0:24

About this video

Give a thumbs up 👍🏻 if my code was useful to you. Showing compilation and execution of my code in Python 3, which is capable of Encrypting, Decrypting, Brute force Attacking using Caesar Cipher cryptography. #python #sublime #caesarcipher #cryptography Develop a single program using any programming language (e.g. Java, Python, C++, etc) that: a. Encrypts and decrypts a message using Cesar’s Cipher. The user encrypting the message is prompted to enter a message and then a key that indicates the displacement. The user decrypting the message is prompted to enter the encrypted message and the key. b. Decrypts and displays all (26) possible solutions. # Writen by Arvin Babaei #Caesar Cipher cryptography code in Python 3 def encrypt(message, key): encrypt_str = '' for ch in message: if ch.isupper(): encrypt_str += chr(ord('A') + ((ord(ch) - ord('A') + key + 26) % 26)) elif ch.islower(): encrypt_str += chr(ord('a') + ((ord(ch) - ord('a') + key + 26) % 26)) else: encrypt_str += ch return encrypt_str def decrypt (message, key): decrypt_str = '' for ch in message: if ch.isupper(): decrypt_str += chr(ord('A') + ((ord(ch) - ord('A') - key + 26) % 26)) elif ch.islower(): decrypt_str += chr(ord('a') + ((ord(ch) - ord('a') - key + 26) % 26)) else: decrypt_str += ch return decrypt_str def brute (message, key): brute_str = '' for ch in message: if ch.isupper(): brute_str += chr(ord('A') + ((ord(ch) - ord('A') - key + 26) % 26)) elif ch.islower(): brute_str += chr(ord('a') + ((ord(ch) - ord('a') - key + 26) % 26)) else: brute_str += ch return brute_str if __name__ == '__main__': while True: input_message = input("Enter message: ") option = input("Encrypt(E) or Decrypt(D) or Brute froce (B)?: ") if option.lower() == 'e': shift_amount = int(input("Enter key: ")) print(encrypt(input_message, shift_amount)) elif option.lower() == 'd': shift_amount = int(input("Enter key: ")) print(decrypt(input_message, shift_amount)) elif option.lower() == 'b': for shift_amount in range(26): print ("using key: " + str(shift_amount)) print(brute(input_message, shift_amount)) else: print("please enter valid input") go_again = input("Go again?(Y/N):") if go_again.lower() == 'n': break;

Video Information

Views
57

Total views since publication

Likes
2

User likes and reactions

Duration
0:24

Video length

Published
Sep 22, 2020

Release date

Quality
hd

Video definition

Related Trending Topics

LIVE TRENDS

This video may be related to current global trending topics. Click any trend to explore more videos about what's hot right now!

THIS VIDEO IS TRENDING!

This video is currently trending in France under the topic 'h'.

Share This Video

SOCIAL SHARE

Share this video with your friends and followers across all major social platforms. Help spread the word about great content!