diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..fbb5dc3 --- /dev/null +++ b/.eslintrc @@ -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 + } +} diff --git a/README.md b/README.md index e2577d6..6bca7db 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,135 @@ -# Cifrado César +CIFRADO CÉSAR +============= -> Recuerda seguir siempre esta [guía de estilos](https://github.com/Laboratoria/js-style-guide/) +### Se puede acceder a este proyecto en +[Github](https://github.com/Tayrih/cifrado_cesar_power_code "Github") -Crea una web que pida, por medio de un `prompt()`, una frase al usuario y -devuelva el mismo mensaje encriptado según el -[algoritmo de Cifrado César](https://en.wikipedia.org/wiki/Caesar_cipher) -con el parámetro de desplazamiento de **33 espacios hacia la derecha** +Índice +------ +* [Introducción](#cabecera1) +* [Pseudocódigo](#cabecera2) +* [Diagrama de flujo](#cabecera3) +* [Autoras](#cabecera4) +* [Fecha](#cabecera5) -Por ejemplo: +Introducción +------------------- +Este producto se ha creado para presentarse como proyecto final del primer sprint de programación básica, que forma parte de la malla curricular de Laboratoria. -- Texto original: `ABCDEFGHIJKLMNOPQRSTUVWXYZ` -- Texto codificado: `HIJKLMNOPQRSTUVWXYZABCDEFG` - -## Entregables +En este proyecto final, titulado “Cifrado César”, se encuentra una carpeta llamada “Javascript”, que contiene la aplicación en la que se encuentra el código del programa conformado por tres funciones: ***validación de dato***, ***cifrado*** y ***descifrado***, y un método que evalúa qué dirección tomar. Además, se encuentra un archivo HTML que presenta el despliegue de un menú con tres opciones: **cifrado**, **descifrado** y **salir**, las que ejecutan un comando en el programa. Asimismo, se encuentra un archivo markdown, titulado “README”, que incluye un enlace a este proyecto en github en la parte superior, un índice con las subdivisiones de ese contenido, una introducción al proyecto, un pseudocódigo que describe el funcionamiento del programa por medio de un lenguaje humano que facilita su entendimiento, y un diagrama de flujo que muestra de forma estructurada y ordenada cuál es el recorrido del dato que ingresa el usuario y el resultado que se imprime en la página web acompañado de un mensaje condicionado al comando por el que se haya optado. -Para cada producto debes entregar **un repositorio de GitHub** que -contenga: -1. Archivo `README.md` que explique el **pseudocódigo** de tu solución y su -**diagrama de flujo** -2. Archivo `app.js` con el **código** de tu solución -3. Archivo `index.html` vinculado con tu `app.js` +Pseudocódigo +------------ +Funcion cipher ( secret) + + definir newPhrase como caracter + newPhrase = '' -## Tips + definir toAscci como entero + toAscci =caracter convertido a Ascii -A continuación un video de Michelle que te lleva a través de la fórmula -matemática del Cifrado César y un par de cosas más que debes saber para -resolver este reto. ¡Escúchala con detenimiento y sigue sus consejos! :) + Para j=0 Hasta tamaño de secret Con Paso 1 Hacer + + Si (toAscci > 64 y toAscci < 91) Entonces + escribir newPhrase = newPhrase + Ascci convertido a caracter mayusculas ((toAscci - 65 + 33) % 26 + 65)); + + Si no si + (toAscci > 96 && toAscci < 123) Entonces + escribir newPhrase = newPhrase + Ascci convertido a caracter minusculas((toAscci - 97 + 33) % 26 + 97)); + sino + escribir newPhrase; + Fin Si + Fin Para + +Fin Funcion -[](https://www.youtube.com/watch?v=zd8eVrXhs7Y) -También te compartimos más información de lo que Michelle te ha explicado -en el video anterior: -- [Aprende más sobre `charCodeAt()`](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/String/charCodeAt) -- [Aprende más sobre `String.fromCharCode()`](https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/String/fromCharCode) -- [Aprende más sobre `ASCII`](http://conceptodefinicion.de/ascii/) -## Consideraciones específicas +Funcion decipher( secret) + + definir newPhrase como caracter + newPhrase = '' -1. Tu programa debe ser capaz de cifrar y descifrar tanto letras - mayúsculas como minúsculas. La fórmula para descifrar es: `(x - n) % 26` -2. Tu código debe estar compuesto por 2 funciones con los siguientes - nombres: `cipher` y `decipher` -3. El usuario no debe poder ingresar un campo vacío o que contenga números + definir toAscci como entero + toAscci =caracter convertido a Ascii -## Criterios de evaluación + Para i=0 Hasta tamaño de secret Con Paso 1 Hacer + + Si (toAscci > 64 y toAscci < 91) Entonces + escribir newPhrase = newPhrase + Ascci convertido a caracter mayusculas ((toAscci - 65 - 33 + 26*2) % 26 + 65)); + + Si no si + (toAscci > 96 && toAscci < 123) Entonces + escribir newPhrase = newPhrase + Ascci convertido a caracter minusculas((toAscci - 97 - 33 + 26*2) % 26 + 97)); + sino + escribir newPhrase; + Fin Si + Fin Para + +Fin Funcion -Se tomarán en cuenta las siguientes consideraciones a la hora de evaluar tu solución: -1. Nombramiento de variables -2. Indentación -3. Validación de input: el usuario no debe poder ingresar un campo vacío o de tipo que no corresponda -4. Estructura de tus archivos -5. Archivo `README.md` correctamente redactado -6. Uso de comentarios para hacer tu código más legible -7. Que el programa cumpla con el propósito requerido + + + +Funcion validate( date) + + + Para i=0 Hasta tamaño "date" Con Paso 1 Hacer + + Si (el Ascii de date > 64 y el Ascii de date< 91) o (el Ascii de date > 96 y el Ascii de date < 123)) + escribir date; //condicionamos a que solo se ingrese letras o mayusculas o minusculas pasando a ascii, una vez convertido condicionamosa que este entre el rango + Si no si ((date igual valor nulo)) + escribir "Error"; + sino + escribir "Error"; + Fin Si + Fin Para + +Fin Funcion + + +~~~ + Segun menu + var menu = "Mostramos al usuario un meno con opciones a elegir (1(cifrar), 2(decifrar), 3(salir ); + definir phrase como caracter; + + opcion_1: + phrase = 'Ingrese un texto a cifrar' + ejecutar (pharse es evaluada en funcion cipher) + escribir texto cifrado; + break; + opcion_2: + phrase = 'Ingrese un texto a descifrar' + ejecutar (pharse es evaluada en funcion decipher) + escribir texto descifrado; + break; + + De Otro Modo: + escribir ('Gracias'); + break; + por defecto: + mostrar una mensaje('Vuelva a realizar el proceso, recuerde ingresar un numero valido de la lista'); + +Fin Segun +~~~ + +Diagrama de flujo +----------------- + + +Autoras +------ +* Tahirih Jaliri Pancca +* Lizbeth Félix Peña +* Gaby Mamani Flores +* Laura Jimenez Hidalgo +* Kattia Rojas +* Kamaly Zapana Lorenzo +* Shannon Rivera Aranibal +* Mily Quispe Yura + +Fecha +----- +12/10/2017 diff --git a/assets/docs/img1.jpg b/assets/docs/img1.jpg new file mode 100644 index 0000000..d227a23 Binary files /dev/null and b/assets/docs/img1.jpg differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..098885c --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ + + + + +
+[ERROR]'); // no ingrese nada + else + return document.write('
[ERROR]'); // ingrese numeros o simbolos en el primer valor + + } + + + + + + +/*var menu = prompt ('MENU PRINCIPAL CIFRADO CESAR \n\n' + '1- Para cifrar frases \n\n ' + '2.- Para decifrar frases \n\n' + '3.- Salir'); +var phrase; +switch (menu) { + case "1": + phrase = prompt ('Ingrese un texto a cifrar'); + document.write('
El texto cifrado es: \n\n
' + cipher(validate(phrase))); // la frase ingresada primero es validada y luego pasa a la funcion cipher + break; + case "2": + phrase = prompt ('Ingrese un texto a descifrar'); + document.write('El texto descifrado es: \n\n
' + decipher(validate(phrase))); // la frase ingresada primero es validada y luego pasa a la funcion decipher + break; + case "3": + document.write('Gracias'); + break; + default: + alert('Vuelva a realizar el proceso, recuerde ingresar un numero valido de la lista'); + +}*/ \ No newline at end of file diff --git a/node_modules/.bin/acorn b/node_modules/.bin/acorn new file mode 100644 index 0000000..558ebb9 --- /dev/null +++ b/node_modules/.bin/acorn @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../acorn/bin/acorn" "$@" + ret=$? +else + node "$basedir/../acorn/bin/acorn" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/acorn.cmd b/node_modules/.bin/acorn.cmd new file mode 100644 index 0000000..45c0c3d --- /dev/null +++ b/node_modules/.bin/acorn.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\acorn\bin\acorn" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\acorn\bin\acorn" %* +) \ No newline at end of file diff --git a/node_modules/.bin/eslint b/node_modules/.bin/eslint new file mode 100644 index 0000000..9f3ac31 --- /dev/null +++ b/node_modules/.bin/eslint @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../eslint/bin/eslint.js" "$@" + ret=$? +else + node "$basedir/../eslint/bin/eslint.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/eslint.cmd b/node_modules/.bin/eslint.cmd new file mode 100644 index 0000000..009a9ae --- /dev/null +++ b/node_modules/.bin/eslint.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\eslint\bin\eslint.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\eslint\bin\eslint.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/esparse b/node_modules/.bin/esparse new file mode 100644 index 0000000..2525527 --- /dev/null +++ b/node_modules/.bin/esparse @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@" + ret=$? +else + node "$basedir/../esprima/bin/esparse.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/esparse.cmd b/node_modules/.bin/esparse.cmd new file mode 100644 index 0000000..064f58e --- /dev/null +++ b/node_modules/.bin/esparse.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\esprima\bin\esparse.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\esprima\bin\esparse.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/esvalidate b/node_modules/.bin/esvalidate new file mode 100644 index 0000000..2137cd5 --- /dev/null +++ b/node_modules/.bin/esvalidate @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@" + ret=$? +else + node "$basedir/../esprima/bin/esvalidate.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/esvalidate.cmd b/node_modules/.bin/esvalidate.cmd new file mode 100644 index 0000000..8dfaec0 --- /dev/null +++ b/node_modules/.bin/esvalidate.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\esprima\bin\esvalidate.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\esprima\bin\esvalidate.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/js-yaml b/node_modules/.bin/js-yaml new file mode 100644 index 0000000..460d9df --- /dev/null +++ b/node_modules/.bin/js-yaml @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@" + ret=$? +else + node "$basedir/../js-yaml/bin/js-yaml.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/js-yaml.cmd b/node_modules/.bin/js-yaml.cmd new file mode 100644 index 0000000..ae8e7bc --- /dev/null +++ b/node_modules/.bin/js-yaml.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\js-yaml\bin\js-yaml.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\js-yaml\bin\js-yaml.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/mkdirp b/node_modules/.bin/mkdirp new file mode 100644 index 0000000..4b00467 --- /dev/null +++ b/node_modules/.bin/mkdirp @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@" + ret=$? +else + node "$basedir/../mkdirp/bin/cmd.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/mkdirp.cmd b/node_modules/.bin/mkdirp.cmd new file mode 100644 index 0000000..0d2cdd7 --- /dev/null +++ b/node_modules/.bin/mkdirp.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\mkdirp\bin\cmd.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\mkdirp\bin\cmd.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/rimraf b/node_modules/.bin/rimraf new file mode 100644 index 0000000..3cebd6e --- /dev/null +++ b/node_modules/.bin/rimraf @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../rimraf/bin.js" "$@" + ret=$? +else + node "$basedir/../rimraf/bin.js" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/rimraf.cmd b/node_modules/.bin/rimraf.cmd new file mode 100644 index 0000000..9333ec6 --- /dev/null +++ b/node_modules/.bin/rimraf.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\rimraf\bin.js" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\rimraf\bin.js" %* +) \ No newline at end of file diff --git a/node_modules/.bin/semver b/node_modules/.bin/semver new file mode 100644 index 0000000..d592e69 --- /dev/null +++ b/node_modules/.bin/semver @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../semver/bin/semver" "$@" + ret=$? +else + node "$basedir/../semver/bin/semver" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/semver.cmd b/node_modules/.bin/semver.cmd new file mode 100644 index 0000000..37c00a4 --- /dev/null +++ b/node_modules/.bin/semver.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\semver\bin\semver" %* +) \ No newline at end of file diff --git a/node_modules/.bin/which b/node_modules/.bin/which new file mode 100644 index 0000000..cbe872c --- /dev/null +++ b/node_modules/.bin/which @@ -0,0 +1,15 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + "$basedir/node" "$basedir/../which/bin/which" "$@" + ret=$? +else + node "$basedir/../which/bin/which" "$@" + ret=$? +fi +exit $ret diff --git a/node_modules/.bin/which.cmd b/node_modules/.bin/which.cmd new file mode 100644 index 0000000..588f44d --- /dev/null +++ b/node_modules/.bin/which.cmd @@ -0,0 +1,7 @@ +@IF EXIST "%~dp0\node.exe" ( + "%~dp0\node.exe" "%~dp0\..\which\bin\which" %* +) ELSE ( + @SETLOCAL + @SET PATHEXT=%PATHEXT:;.JS;=;% + node "%~dp0\..\which\bin\which" %* +) \ No newline at end of file diff --git a/node_modules/acorn-jsx/LICENSE b/node_modules/acorn-jsx/LICENSE new file mode 100644 index 0000000..6d1e4f4 --- /dev/null +++ b/node_modules/acorn-jsx/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2012-2014 by Ingvar Stepanyan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/acorn-jsx/README.md b/node_modules/acorn-jsx/README.md new file mode 100644 index 0000000..cd9674c --- /dev/null +++ b/node_modules/acorn-jsx/README.md @@ -0,0 +1,64 @@ +# Acorn-JSX + +[](https://travis-ci.org/RReverser/acorn-jsx) +[](https://www.npmjs.org/package/acorn-jsx) + +This is plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It was created as an experimental alternative, faster [React.js JSX](http://facebook.github.io/react/docs/jsx-in-depth.html) parser. + +According to [benchmarks](https://github.com/RReverser/acorn-jsx/blob/master/test/bench.html), Acorn-JSX is 2x faster than official [Esprima-based parser](https://github.com/facebook/esprima) when location tracking is turned on in both (call it "source maps enabled mode"). At the same time, it consumes all the ES6+JSX syntax that can be consumed by Esprima-FB (this is proved by [official tests](https://github.com/RReverser/acorn-jsx/blob/master/test/tests-jsx.js)). + +**UPDATE [14-Apr-2015]**: Facebook implementation started [deprecation process](https://github.com/facebook/esprima/issues/111) in favor of Acorn + Acorn-JSX + Babel for parsing and transpiling JSX syntax. + +## Transpiler + +Please note that this tool only parses source code to JSX AST, which is useful for various language tools and services. If you want to transpile your code to regular ES5-compliant JavaScript with source map, check out the [babel transpiler](https://babeljs.io/) which uses `acorn-jsx` under the hood. + +## Usage + +You can use module directly in order to get Acorn instance with plugin installed: + +```javascript +var acorn = require('acorn-jsx'); +``` + +Or you can use `inject.js` for injecting plugin into your own version of Acorn like following: + +```javascript +var acorn = require('acorn-jsx/inject')(require('./custom-acorn')); +``` + +Then, use `plugins` option whenever you need to support JSX while parsing: + +```javascript +var ast = acorn.parse(code, { + plugins: { jsx: true } +}); +``` + +Note that official spec doesn't support mix of XML namespaces and object-style access in tag names (#27) like in `