Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"keyword-spacing": 1,
"space-before-function-paren": [1, "never"],
"eqeqeq": 1,
"space-infix-ops": 1,
"comma-spacing": 1,
"brace-style": 1,
"no-multiple-empty-lines": 1,
"camelcase": 1,
"func-call-spacing": 1,
"key-spacing": 1,
"semi": 1,
"no-floating-decimal": 1,
"no-multi-spaces": 1,
"object-property-newline": 1,
"padded-blocks": [1, "never"],
"space-before-blocks": 1,
"space-in-parens": 1,
"spaced-comment": 1,
"quotes": [1, "single"],
"id-length": [1, { "exceptions": ["i", "j", "x"] }],
"indent": [1, 2],
"no-array-constructor": 1
}
}
57 changes: 0 additions & 57 deletions README.md

This file was deleted.

13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CIPHER AND DECIPHER</title>
</head>
<body>
<h1>Cifrado Cesar</h1>
<script type="text/javascript" src ="js/app.js">

</script>
</body>
</html>
42 changes: 42 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* creando funcion Cipher y consultando al usuario*/
function cipher() {
var question = prompt('Escribe tu nombre');
/* creando bucle para que en caso de que el usuario no ingrese informacion se le solicite hacerlo*/
while (question === '') {
question = prompt('escribe algo');
}
/* recorriendo frase del usuario */
for (var i = 0; i < question.length; i++) {
/* de encontrar cifra numerica o un vacio solicitamos nueva informacion*/
while (parseInt(question[i]) % 1 === 0) {
question = prompt('No coloques numero');
while (question === '') {
question = prompt('escribe algo');
}
}
}
/* cifrando(primero convertir a mayusculas y aplicar cifrado)*/
var questionMayus = question.toUpperCase();
var str = '';
for (var j = 0; j < questionMayus.length; j++) {
var newPosition = (questionMayus.charCodeAt(j) - 65 + 33) % 26 + 65;
var letterCifher = String.fromCharCode(newPosition);
str += letterCifher;
}
return str;
}
/* creando funcion de decifrado*/
function decipher(str) {
/* asignamos una variable , la cual almacenará la palabra decifrada*/
var decipherWord = '';
/* recorriendo el array cifrado y ejecutando formula*/
for (var ij = 0; ij < str.length; ij++) {
var retroPosition = (str.charCodeAt(ij) + 65 - 33) % 26 + 65;
var letterCesar = String.fromCharCode(retroPosition);
decipherWord += letterCesar;
}
alert('tu nombre cifrado es' + ' ' + str);
alert('tu nombre decifrado es' + ' ' + decipherWord);
}

decipher(cipher());