I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea:
Write a program that takes 2 inputs, a string and integer:
- the message to encode or decode
- how far to shift
You can input in a function call, and output in any legal way
twist:
it must work with any printable ascii character.
Example code:
def ceasar_cipher(message,shift):
o = ""
for n in message:
o+=(chr(ord(n)+shift))
return o
python 3 examples:
input:
ceasar_cipher(“hello, world”,13):
output:
"uryy|9-\x84|\x7fyq."
This is code-golf, so shortest code in bytes wins.
The output should be a string
-Can raise an error if it will go past ASCII-characters, or just not shift said characters
Good luck!