-
Notifications
You must be signed in to change notification settings - Fork 116
subiendo mis archivos #72
base: master
Are you sure you want to change the base?
Changes from 1 commit
87dc76d
59a6706
deef5ad
99ec373
7c51039
5ef9b70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| var phrase = prompt('Write here'); | ||
|
|
||
| function cipher(word) { | ||
|
|
||
| var strCipher = '' ; | ||
| for (var i = 0; i < word.length; i++) { | ||
| // turn word into ASCII code. | ||
| var letter = word.charCodeAt(i); | ||
| // if 'word' is uppercase... | ||
| if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') { | ||
| // using the formula. | ||
| var num = (letter - 65 + 33) % 26 + 65; | ||
| // num into string | ||
| strCipher =+ String.fromCharCode(num); | ||
| // if 'word' is lowercase... | ||
| } else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') { | ||
| // using the formula. | ||
| var num2 = (letter - 97 + 33) % 26 + 97; | ||
| // num into string | ||
| strCipher = strCipher + String.fromCharCode(num2); | ||
| } else { | ||
| alert('Write Again, please.'); | ||
| } | ||
| } | ||
| return alert(strCipher); | ||
| } | ||
| cipher(phrase); | ||
|
|
||
|
|
||
| function decipher(word) { | ||
| var strDecipher = '' ; | ||
| for (var i = 0; i < word.length; i++ ) { | ||
| var letter = word.charCodeAt(i); | ||
|
|
||
| if (Number.isNaN(parseInt(word)) && 65 <= letter && letter <= 90 && word !== '') { | ||
|
||
| // añadir la formula y almaceno en num | ||
| var num = (letter - 65 + 26) % 26 + 65; | ||
|
|
||
| strDecipher = strDecipher + String.fromCharCode(num); | ||
| } else if (Number.isNaN(parseInt(word)) && 97 <= letter && letter <= 122 && word !== '') { | ||
|
||
| var num2 = (letter - 97 + 26) % 26 + 97; | ||
| strDecipher = strDecipher + String.fromCharCode(num2); | ||
| } else { | ||
| alert('Write Again, please.'); | ||
|
||
| } | ||
| } | ||
| return alert(strDecipher); | ||
| } | ||
| decipher(phrase); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Cifrado César</title> | ||
| </head> | ||
| <body> | ||
| <h1>Coding and Decoding</h1> | ||
| <p>Write a word, and we show you the same word coded and decoded.</p> | ||
| <script type="text/javascript" src="js/app.js"></script> | ||
| </body> | ||
| </html> |
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 cifrar a menos que el usuario lo pida. Puedes hacer un menu donde el usuario pueda ingresar "1" para cifrar o "2" para descifrar