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 #24 - Cifrado Cesar #6123

Merged
merged 2 commits into from
Dec 20, 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
36 changes: 36 additions & 0 deletions Retos/Reto #24 - CIFRADO CÉSAR [Fácil]/python/adridoce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
/*
* Crea un programa que realize el cifrado César de un texto y lo imprima.
* También debe ser capaz de descifrarlo cuando así se lo indiquemos.
*
* Te recomiendo que busques información para conocer en profundidad cómo
* realizar el cifrado. Esto también forma parte del reto.
*/
"""

def cifrar_texto(cadena):
texto = cadena.lower()
texto_cifrado = ""

for caracter in texto:
texto_cifrado += chr(ord(caracter) + 5)
return texto_cifrado

def descifrar_texto(cadena):
texto = cadena.lower()
texto_descifrado = ""

for caracter in texto:
texto_descifrado += chr(ord(caracter) - 5)
return texto_descifrado

print("Selecciona una opcion\n")
print("1. Cifrar texto\n")
print("2. Descifrar texto\n")
opcion = input("Opcion:")
texto = input("Introduce el texto\n")

if int(opcion) == 1:
print(cifrar_texto(texto))
elif int(opcion) == 2:
print(descifrar_texto(texto))