python ascii caesar cipher
def ascii_caesar_shift(message, distance):
encrypted = ""
for char in message:
value = ord(char) + distance
encrypted += chr(value % 128) #128 for ASCII
return encrypted
python ascii caesar cipher
def ascii_caesar_shift(message, distance):
encrypted = ""
for char in message:
value = ord(char) + distance
encrypted += chr(value % 128) #128 for ASCII
return encrypted
python caesar cipher
plaintext = input("Please enter your plaintext: ")
shift = input("Please enter your key: ")
alphabet = "abcdefghijklmnopqrstuvwxyz"
ciphertext = ""
# shift value can only be an integer
while isinstance(int(shift), int) == False:
# asking the user to reenter the shift value
shift = input("Please enter your key (integers only!): ")
shift = int(shift)
new_ind = 0 # this value will be changed later
for i in plaintext:
if i.lower() in alphabet:
new_ind = alphabet.index(i) + shift
ciphertext += alphabet[new_ind % 26]
else:
ciphertext += i
print("The ciphertext is: " + ciphertext)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us