Sep-09-2020, 09:36 AM
Hi eveyone,
I'm currently working on a ceasar cipher project. I pretty much have the basic structure down and the program is able to auto-encrypt the input ( given text ) by +1 position. I can change the positioning either by "int(input)"option or by directly adding to the code. Now I would like to change the position of each letter separately as follows: +1 +2 +3 +4 +5 etc.
Example 1 with input option:
. Do i have to add another loop to the function or do I change the current loop? Any hints, help would be much appreciated.
Thanks
I'm currently working on a ceasar cipher project. I pretty much have the basic structure down and the program is able to auto-encrypt the input ( given text ) by +1 position. I can change the positioning either by "int(input)"option or by directly adding to the code. Now I would like to change the position of each letter separately as follows: +1 +2 +3 +4 +5 etc.
Example 1 with input option:
def ascii_code(message):
print("Decryption with ASCII-output")
for symbol in message:
print(ord(symbol), end = " ")
print("\n")
def caesar(message):
print("Caesar Decryption:")
shift = int(input("Please enter the shift value: "))
for letter in message:
if letter.isupper():
print(chr((ord(letter)+ shift - 65) % 26 + 65), end = " ")
else:
print(chr((ord(letter)+ shift - 97) % 26 + 97), end = " ")
print("\n")
enter = input("Please enter your message: ")
print("The original message is:", enter, "\n")
ascii_code(enter)
caesar(enter)Example 2 with manual entry option with shift value +1:def ascii_code(message):
print("Decryption with ASCII-output")
for symbol in message:
print(ord(symbol), end = " ")
print("\n")
def caesar(message):
print("Caesar Decryption:")
shift = 1
for letter in message:
if letter.isupper():
print(chr((ord(letter)+ shift - 65) % 26 + 65), end = " ")
else:
print(chr((ord(letter)+ shift - 97) % 26 + 97), end = " ")
print("\n")
enter = input("Please enter your message: ")
print("The original message is:", enter, "\n")
ascii_code(enter)
caesar(enter)My message is: Iamsecret. Currently the output is Jbntfsfu using +1. I would like the encryption to be +1 J / +2 c / +3 p and so on. I've tried numerous routes, but i keep
. Do i have to add another loop to the function or do I change the current loop? Any hints, help would be much appreciated. Thanks
