This repository was archived by the owner on Jan 8, 2020. It is now read-only.
modificando-js-Longhi-Valverde#70
Open
longhi wants to merge 2 commits intoLaboratoria-learning:masterfrom
Open
modificando-js-Longhi-Valverde#70longhi wants to merge 2 commits intoLaboratoria-learning:masterfrom
longhi wants to merge 2 commits intoLaboratoria-learning:masterfrom
Conversation
|
Hola @longhi está pendiente un detalle para poder enviar tu // SE CREA DOS FUNCIONES //
// PRIMERA FUNCION QUE CIFRE //
function cipher() {
// MEDIO DE UN PROMPT EL USUARIO DARA SU FRASE//
var sentence = prompt('Ingrese la frase que desea cifrar');
// LA FRASE Y SEPARAMOS POR CADA CARACTER
var convertEncrypt = sentence.split('');
// AGREGARE UN ARRAY VACIO PARA QUE ENTRE LOS CARACTERES ENCRIPTADOS
var pushEnncrypt = [];
// ENCRIPTAR UNO POR UNO MEDIANTE UN FOR
for (var i = 0; i < convertEncrypt.length;i++) {
// SE HACE UNA NUEVA variable QUE LA FRASE devuelve un número indicando
// el valor Unicode del carácter en el índice proporcionado
var newcharacterPosition = convertEncrypt[i].charCodeAt();
// utilizamos la formula para encriptar
var characterPosition = ((newcharacterPosition - 65 + 33) % 26 + 65);
// devuelve una cadena creada mediante el uso de una secuencia de valores // DE LA FORMULA QUE HICIMOS ARRIBA
var pushPosition = characterPosition.String.fromCharCode(characterPosition);
// AHORA AGREGAMOS Y JUNTAMOS LO CIFRADO EN EL ARRAY VACIO
pushEnncrypt.push(pushPosition) && pushEnncrypt.join(pushPosition);
}
// RETORNA AL ARRAY VACIO
return pushEnncrypt();
}
cipher();
// SEGUNDA FUNCION QUE DECIFRA
function decipher() {
// ENTRAR UN PROMPT PARA QUE EL USUARIO ME DEVUELVA LO QUE SE LE indica
var phrase = prompt('Ingresa lo que deseas decifrar');
// LOS CARACTERES INGRESADOS SE SEPARAN
var phraseSplit = phrase.split();
// COLOCAMOS UN ARRAY VACIO PARA LUEGO EL DECIFRADO ENTRE
var pushDecipher = [];
// MEDIANTE UN FOR LO QUE INGRESO EL USUARIO COMENZARA A CONTAR UNO POR UNO
for (var i = 0; i < phraseSplit.length; i++) {
// EL INDICE ES tODO LO QUE ENTRA EL USUARIO
var newDecipher = phraseSplit[i];
// SE PONE LA FORMULA PARA DECIFRARLO
var starDecipher = (newDecipher - 33) % 26;
// EL RESULTADO SE AGREGA Y JUNTA LOS CARACTERES AL ARRAY VACIO
pushDecipher.push(starDecipher) && pushDecipher.join(starDecipher);
}
return pushDecipher(); // RETONAR AL ARRAR VACIO
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hola eso es mi cifrado cesar