Learn How Caesar Used Cipher Magic! 🔒✨ #CaesarCipher #SecretsUnveiled #CryptoHistory#python#coding

preview_player
Показать описание
Caesar cipher is one of the simplest and oldest encryption techniques, attributed to Julius Caesar who used it to protect sensitive messages. In this method, each letter in the plaintext is shifted a fixed number of positions down or up the alphabet. For instance, with a shift of 3, 'A' becomes 'D', 'B' becomes 'E', and so forth. Despite its simplicity, the Caesar cipher can still provide a basic level of security. The provided Python code demonstrates how to implement this cipher, allowing you to encrypt messages easily.
#python #coding #code #coder#pythonprogramming
Рекомендации по теме
Комментарии
Автор

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# TODO-1: Create a function called 'encrypt' that takes the 'text' and 'shift' as inputs.
def ceaser(start_text, shift_amount, direction_to):
end_text = ""
if direction_to == "decode":
shift_amount *= -1
for letter in start_text:
if letter in alphabet:
position = alphabet.index(letter)
new_position = position + shift_amount
end_text += alphabet[new_position]
else:
end_text += letter
print(f"the {direction_to} word is: {end_text}")


should_continue = True
while should_continue:
direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
text = input("Type your message:\n").lower()
shift = int(input("Type the shift number:\n"))
shift %= 26
ceaser(text, shift, direction)
user_input = input("type 'yes' if you want to do again.otherwise type 'no'")
if user_input == "no":
should_continue = False
print("Goodbye")

Aryan_Singh_coder
visit shbcf.ru