-
Notifications
You must be signed in to change notification settings - Fork 116
Cifrado Cesar de María Alejandra Cabrera Pérez #69
base: master
Are you sure you want to change the base?
Conversation
@developerVilchez |
@@ -0,0 +1 @@ | |||
g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La pagina index.html deberia de tener contenido e importar el javascript usando <script>
// Si el elemento es un string vacio aparece nuevo prompt. | ||
// Si el elemento parseado es >= a cero aparece nuevo prompt. | ||
if (phrase[i] === ' ' || parseInt(phraseToArray[i]) >= 0) { | ||
var text = 'El texto no debe contener espacios ni números, \n escribe el texto a cifrar.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El texto si debe de poder tener espacios!
|
||
// phrase es convertida a masyúscula y en un array con caracteres separados. | ||
|
||
var phraseToArray = phrase.toUpperCase().split(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
que tal si dejamos que la cifra mantenga minusculas como minusculas y mayusculas como mayusculas?
alert('Su texto cifrado es: ' + newArray.join('')); | ||
|
||
// Da opción a descifrar el texto cifrado. | ||
returnDecipher = confirm('¿Desea descifrar el texto cifrado?'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el function de cifrar solo deberia de cifrar. Deberiamos poner toda la logica de descifrar en la otra function.
|
||
// Da opción a cifrar el texto descifrado. | ||
|
||
returnDecipher = confirm('¿Desea descifrar el texto cifrado?'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No deberias de tener que preguntar si desea descifrar el texto, porque ya estamos en la function para descifrar.
phraseToArray = prompt(text2).toUpperCase().split(''); | ||
|
||
// El valor de i debe regresar a cero para volver a iterar por cada elemento. | ||
i = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no me gusta cambiar el valor de los indices de for loops dentro de los for loops. Tal vez podrias hacer un helper function para verificar el input y hacer un while loop. Algo como:
phraseToArray = ....
while(!valid(phraseToArray)) {
phraseToArray = ...
}
} | ||
} | ||
|
||
decipher(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no deberiamos de llamar decipher y cipher a menos que el usuario quiera hacerlo.
tal vez podrias hacer un menu donde el usuario puede poner 1 para cifrar o 2 para descifrar
Hola, este es mi código del Cifrado Cesar, por favor revíselo quiero seguir mejorando.
Gracias por su tiempo.