Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Cifrado Cesar de María Alejandra Cabrera Pérez #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlejandraCP
Copy link

Hola, este es mi código del Cifrado Cesar, por favor revíselo quiero seguir mejorando.

Gracias por su tiempo.

@Gabx04
Copy link

Gabx04 commented Nov 14, 2017

@developerVilchez eslint OK.

@@ -0,0 +1 @@
g
Copy link

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.';
Copy link

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('');
Copy link

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?');
Copy link

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?');
Copy link

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;
Copy link

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();
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants