Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reto mouredev#24 - Python #3839

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Retos/Reto #24 - CIFRADO CÉSAR [Fácil]/python/maurighar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
alfabeto_normal = 'abcdefghijklmnopqrstuvwxyz 1234567890'

def encode_cesar(message:str, shift:int) -> str:
message = message.lower()
message_cifer = ''
for string in message:
index = alfabeto_normal.find(string)
if index >= 0:
message_cifer += alfabeto_normal[index + shift]
else:
message_cifer += '#'

return message_cifer

def decode_cesar(message:str, shift:int) -> str:
message = message.lower()
message_clear = ''
for string in message:
index = alfabeto_normal.find(string)
if index >= 0:
message_clear += alfabeto_normal[index - shift]
else:
message_clear += '#'

return message_clear

if __name__ == "__main__":
mensaje = 'te recomiendo que busques informacion para conocer en profundidad'
mensaje = 'prueba 234, si (?/7Ú\),\n MAYUSCULAS'
print(encode_cesar(mensaje, 3))

mensaje = 'wh3uhfrplhqgr3txh3exvtxhv3lqirupdflrq3sdud3frqrfhu3hq3surixqglgdg'
mensaje = 'suxhed3567#3vl3###0####3pd1xvfxodv'
print(decode_cesar(mensaje, 3))