How to Encrypt Data Using Caesar Cipher in Python (Simple)

preview_player
Показать описание
How to Encrypt Data Using Caesar Cipher in Python (Simple)

Greetings, it is Max ODidily here and today I am here with a Python tutorial on how to encrypt a string using Caesar Cipher.

Simply put, the Caesar Cipher is a substitution cipher that shifts the letters of the alphabet a certain number of places down the alphabet.

For example, if the shift is 3, every letter in the message is replaced with the letter that is 3 positions down the alphabet. In this way, the message is scrambled and can only be deciphered by someone who knows the shift value.

With this tutorial, you'll learn how to implement the Caesar Cipher algorithm in Python to encrypt your own messages.

Thanks for watching this tutorial on how to encrypt using Caesar Cipher in Python.

How to Encrypt Data Using Caesar Cipher in Python (Simple)
Рекомендации по теме
Комментарии
Автор

for some reason its not printing, are you able to help? the code i put in is
def encrypt(text, shift):
text = text.lower()
encrypted_text=""
for char in text:
if char.islower():
encrypted_text += chr((ord(char)+ shift -97) % 26 + 97)
else:
encrypted_text += char
return encrypted_text

originalMessage = input("enter text to ecrypt ")
encryptedMessage = encrypt(originalMessage, 2)
print(encryptedMessage)

OmarG
Автор

Shouldn't it ask the user to enter the text?

Squirrellium