Code 70: Caesar Cypher Encryption using Python | 365 days of Code

Publicado el: 17 marzo 2021
en el canal de: Code House
64
1

Here is the python program for the Caesar Cypher Encryption.
In this, we replace each plaintext letter with a different one a fixed number of places down the alphabet.

Code -
import string
all_alphabets = string.ascii_lowercase + string.ascii_uppercase # all_aphabets = "abcd....xyzABC.....XYZ"
sentence = "Hello World"
key = 2 # Try to encrypt with key 1. Next letter of H will be I, e will be f, l will be m
Hello World
Key = 1: Ifmmp Xpsme
Key = 2: Jgnnq Yqtnf

encr_sent = ""
for each in sentence:
index = all_alphabets.find(each) # Getting the index of the alphabet, if existing in all_alphabets variable.
if index >= 0:
encr_sent += all_alphabets[(index+key)%52] # Adding the key to index
else:
encr_sent += each
print(encr_sent)

If you have any confusion in any line number, feel free to comment.


En esta página del sitio puede ver el video en línea Code 70: Caesar Cypher Encryption using Python | 365 days of Code de Duración hora minuto segunda en buena calidad , que subió el usuario Code House 17 marzo 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 64 veces y le gustó 1 a los espectadores. Disfruta viendo!