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 - python by Rusian69 #3835

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
53 changes: 53 additions & 0 deletions Retos/Reto #24 - CIFRADO CÉSAR [Fácil]/python/Rusian69.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
* 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.
"""
# Lista que se comprobara durante la ejecucion
list_of_words = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0","1", "2", "3", "4", "5", "6", "7", "8", "9", " "]
#funcion
def cipher_cease ():
result = ""
try:
#inicio del sistema
print("Bienvenido al sistema de cifrado Cesar\nDesea cifrar o decodificar un mensaje en este programa\n(C: Para cifrar/D: Para decodificar:)")
insest = str(input("Ingrese su peticion: "))
#sistema de cifrado
if insest.upper() == "C":
word = str(input("Ingrese la palabra a cifrar: "))
code = int(input("Ingrese la clave para el cifrado: "))
for index in word:
vaule = index.upper()
if vaule in list_of_words:
pocition = list_of_words.index(vaule)
result += list_of_words[(pocition + code)]
result = result.lower()
#sistema de decifrado
elif insest.upper() == "D":
word = str(input("Ingrese la palabra a cifrada: "))
code = int(input("Ingrese la clave para el decifralo: "))
for index in word:
vaule = index.upper()
if vaule in list_of_words:
pocition = list_of_words.index(vaule)
result += list_of_words[(pocition - code)]
result = result.capitalize()
#contro de errorres en inicio
else:
print ({"Error": "Parametro inicial no aceptado"})
sentenc = str(input("Desea arracar el programa denuevo?\n(S: si / N: no)\nColoque su peticion: "))
if sentenc.upper == "S":
cipher_cease ()
elif sentenc.upper == "N":
pass
except:
return {"Error": "Sistema no pudo funcionar"}
#resultado
finally:
print("Gracias por usar nuestro servicio de codificacion.")
return result
print(cipher_cease ())