-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cipher #30
Open
paocmoras
wants to merge
34
commits into
Laboratoria:master
Choose a base branch
from
paocmoras:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cipher #30
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c445096
se agrego txt prueba
paocmoras 8275fde
editando html y css
paocmoras 4b869c4
html y css, imagen
paocmoras 0cb65ca
Edito html, html2, css
paocmoras 079eaa3
Estructura terminada(visualmente)
paocmoras 78dae1d
dandole al cipher
paocmoras 3931a89
Update README.md
paocmoras 922ba2a
Update README.md
paocmoras 2c0609a
Update README.md
paocmoras 7bc0037
Update README.md
paocmoras e6d513c
terminando el proyecto
paocmoras 787bc41
agregando imagenes para el readme
paocmoras 16c8cea
Delete README.md
paocmoras ecf4266
readme
paocmoras 7b3b9fb
subiendo todo
paocmoras b3980bf
Create README.md
paocmoras 9a64479
Merge https://github.com/paocmoras/CDMX009-cipher
paocmoras 683b209
imagenes
paocmoras e22adde
modificando readme
paocmoras 1f32f26
modificando readme
paocmoras ab5ca38
js
paocmoras dd8ea62
tratando de entender, index.js
paocmoras b282253
modificando js, html
paocmoras 555ee75
readme-objetivos de aprendizaje
paocmoras ea78b27
objetivos de aprendizaje
paocmoras c5a39e2
acomodando cuadro de bienvenida css
paocmoras 7728ed9
objetivos de aprendizaje
paocmoras dccc6c3
objetivos
paocmoras 66a800c
metiendo imagenes en carpeta
paocmoras 8c84e40
intentando ver imagenes en el readme
paocmoras b3effa3
pasando todo a un solo html y haciendo anotaciones
paocmoras c95184d
boton toggle checked
paocmoras 433fb8b
readme
paocmoras ac3bcb8
borrando carpeta
paocmoras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,82 @@ | ||
const cipher = { | ||
// ... | ||
}; | ||
|
||
export default cipher; | ||
//window valor global, cipher es el objeto | ||
window.cipher = { | ||
//Codificar, cadena de texto, numero de desplazamiento | ||
encode: (string, offset) => { | ||
//variable para que introduzcan la palabra a cifrar | ||
let wordCipher = ""; | ||
//mi ciclo "for" se va a estar ejecutando cada que el usuario introduzca una | ||
//cadena de texto e ira incrementando | ||
for (let i = 0; i < string.length; i++) { | ||
//variable que declara que word es igual a una cadena de texto[incrementar] | ||
let word = string[i]; | ||
//mi variable word solo se va a ejecutar siempre y cuando sea equivalente | ||
//a solo letras | ||
if (word.match(/[a-z]/i)) { | ||
//mi variable word solo se va a ejecutar si mi cadena de texto respeta el | ||
//codigo al caracter tiene que ser igual o mayor a "A" pero igual y menor a "Z" | ||
//del codigo ASCII | ||
if (string.charCodeAt(i) >= 65 && string.charCodeAt(i) <= 90) { | ||
//variable que indica que mi cadena de texto respeta el codigo al caracter menos | ||
// la primera letra de ASCII más numero de desplazamiento(entero) % alfabeto más | ||
// primera letra ASCII. | ||
let textWord = (string.charCodeAt(i) - 65 + parseInt(offset)) % 26 + 65; | ||
//Mi cifrado de palabras va a ser más o igual a la palabra introducida y solo | ||
//pueden ser letras Mayusculas y no numeros | ||
wordCipher += String.fromCharCode(textWord); | ||
//mi variable word solo se va a ejecutar si mi cadena de texto respeta el codigo | ||
// al caracter tiene que ser igual o mayor a "a" pero igual y menor a "z" del | ||
//codigo ASCII | ||
} else if (string.charCodeAt(i) >= 97 && string.charCodeAt(i) <= 122) { | ||
//pero mi cadena de texto debe de respeta el codigo al caracter menos | ||
// la 97 letra "a" de ASCII más numero de desplazamiento(entero) % alfabeto más | ||
//la 97 letra "a" letra ASCII | ||
textWord = (string.charCodeAt(i) - 97 + parseInt(offset)) % 26 + 97; | ||
//Mi cifrado de palabras va a ser más o igual a la palabra introducida y solo | ||
//pueden ser letras minusculas y no numeros | ||
wordCipher += String.fromCharCode(textWord); | ||
} | ||
} else { | ||
wordCipher += word; | ||
} | ||
} | ||
//retorna en Cifrado de palabra | ||
return wordCipher; | ||
}, | ||
//Decodificar, cadena de texto y numero de desplazamiento | ||
decode: (string, offset) => { | ||
//Se asigna una variable para descifrar | ||
let wordDeCipher = ""; | ||
//mi ciclo "for" se va a ejecutar siempre y cuando se introduzca una cadena de | ||
//texto e ira incrementando | ||
for (let i = 0; i < string.length; i++) { | ||
// mi variable declara de mi palabra es igual a una cadena de texto e ira | ||
//incrementando | ||
let wordD = string[i]; | ||
//mi variable dice que solo se pueden introducir letras | ||
if (wordD.match(/[a-z]/i)) { | ||
//mi variable word solo se va a ejecutar si mi cadena de texto respeta el | ||
//codigo al caracter tiene que ser igual o mayor a "A" pero igual y menor a | ||
//"Z" del codigo ASCII | ||
if (string.charCodeAt(i) >= 65 && string.charCodeAt(i) <= 90) { | ||
let textWord = (string.charCodeAt(i) + 65 - parseInt(offset)) % 26 + 65; | ||
//Mi descifrado de palabras va a ser más o igual a la palabra introducida y | ||
//solo pueden ser letras Mayusculas y no numeros | ||
wordDeCipher += String.fromCharCode(textWord); | ||
//mi variable word solo se va a ejecutar si mi cadena de texto respeta el codigo | ||
//al caracter tiene que ser igual o mayor a "a" pero igual y menor a "z" del | ||
//codigo ASCII | ||
} else if (string.charCodeAt(i) >= 97 && string.charCodeAt(i) <= 122) { | ||
//pero mi variable indica que se ejecuta con la formula de codigo ASCII con | ||
//palabras en minusculas | ||
let textWord = (string.charCodeAt(i) - 97 - parseInt(offset))% 26 + 97; | ||
//Mi descifrado de palabras va a ser + o = a una cadena de texto, no numeros | ||
wordDeCipher += String.fromCharCode(textWord); | ||
} | ||
} else { | ||
wordDeCipher += wordD; | ||
} | ||
} | ||
//retornar en Descifrado de palabra | ||
return wordDeCipher; | ||
} | ||
} | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
<header> | ||
<meta charset="utf-8"> | ||
<title>Caesar Cipher</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<div id="root"> | ||
<h1>Hello world!</h1> | ||
</div> | ||
<script src="index.js" type="module"></script> | ||
</body> | ||
<title>Bienvenidos al creador de Password</title> | ||
<link rel="stylesheet" href="style.css"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
</header> | ||
|
||
<main> | ||
|
||
|
||
<div class="contenedor" id="first" class="display_block">; | ||
|
||
<div class= "contenedor1"><h1>¡Advertencia!</h1><br> | ||
|
||
No admite letra "Ñ"<br> | ||
No admite caracteres<br> | ||
No admite numeros | ||
|
||
<!--Boton Entendido--> | ||
<form><br> | ||
<button type="button" id="boton">Entendido</button> | ||
</form> | ||
</div></div> | ||
|
||
<!--Segunda pantalla--> | ||
|
||
<div id="second" class="bienvenidos display_none"> | ||
<h1>Bienvenidos al creador de Password</h1> | ||
|
||
<!--Boton Toggle--> | ||
|
||
<div class="cifra-Descifra">Cifra-Descifra<br> | ||
<input id="myCheckbox" type="checkbox" /></div>; | ||
|
||
|
||
<!--Botones Cifrado y Descifrado--> | ||
<div id="encode-decode"> | ||
<a href="#" id="page-encode"><img src= "img/abierto.png"></a> | ||
<a href="#" id="page-decode"><img src= "img/cerrado.png"></a> | ||
</div> | ||
|
||
<!--display cifrar--> | ||
|
||
<div id="text-encode" class="display_block"><!--Enlazar styledisplay--> | ||
<div class="content-offset"> | ||
<label class="label">Número de desplazamiento</label><br> | ||
<input type="number" id="offset_ci" class="style_offset"><!--enlaza offset a variable y css--> | ||
</div> | ||
<br><textarea id="box-msg-encode" class="box-text-style" placeholder="Introduce el texto a cifrar..."></textarea><br><!--Caja de texto--> | ||
<button id="btn_encode" class="send">Enviar</button><br><!--Boton enviar--> | ||
<div id="msg-encode" class="text-result"><p id="msg-encode-check"></p><!--Demo--> | ||
</div> | ||
<button onclick="location.reload();" class="recharge">Limpiar</button><!--Boton Limpiar--> | ||
</div> | ||
|
||
<!--display descifrar--> | ||
|
||
<div id="text-decode" class= "display_none"><!--Enlazar style.display--> | ||
<div class="content-offset"> | ||
<label class="label">Número de desplazamiento</label><br> | ||
<input type="number" id="offset_des" class="style_offset"><!--enlaza offset a variable y css--> | ||
</div> | ||
<br><textarea id="box-msg-decode" class="box-text-style" placeholder="Introduce el texto a descifrar..."></textarea><br><!--Caja de texto--> | ||
<button id="btn_decode" class="send">Enviar</button><br><!--Boton enviar--> | ||
<div id="msg-decode" class="text-result"><p id="msg-decode-check"></p><!--Demo--> | ||
</div> | ||
<button onclick="location.reload();" class="recharge">Limpiar</button><!--Boton Limpiar--> | ||
</div> | ||
|
||
</section> | ||
|
||
|
||
<script src="cipher.js"></script> | ||
<script src="index.js"></script> | ||
|
||
</main> | ||
<footer></footer> | ||
|
||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,70 @@ | ||
import cipher from './cipher.js'; | ||
window.onload = () => { | ||
|
||
console.log(cipher); | ||
//variable de mi boton "entendido" con el nombre de id "boton" | ||
//nota: se le tiene que poner un div id al comienzo de cada pagina para | ||
//poderla meter en eventos y poder pasar a la siguiente pagina | ||
|
||
const boton = document.getElementById("boton"); | ||
|
||
boton.addEventListener("click", function() { | ||
console.log("Has hecho clic en el botón"); | ||
document.getElementById("first").style.display = "none"; | ||
document.getElementById("second").style.display= "block"; | ||
|
||
}); | ||
|
||
//Boton Toggle | ||
const checkbox = document.getElementById('myCheckbox') | ||
|
||
checkbox.addEventListener('change', (event) => { | ||
if (event.target.checked) { | ||
alert('checked'); | ||
} else { | ||
alert('not checked'); | ||
} | ||
}); | ||
|
||
/*pantalla cifrado*/ | ||
|
||
const cifrado = document.getElementById("page-encode");//se liga a href. | ||
|
||
cifrado.addEventListener("click", function() { | ||
document.getElementById("text-encode").style.display = "none"; | ||
document.getElementById("text-encode").style.display= "block"; | ||
document.getElementById("text-decode").style.display= "none"; | ||
}); | ||
|
||
/*variables para funcionamiento de botones cifrar*/ | ||
|
||
const btnTextEncode = document.getElementById('btn_encode'); | ||
btnTextEncode.addEventListener("click", function() { | ||
//enlaza a caja de texto html y css | ||
let textEncode = document.getElementById("box-msg-encode").value; | ||
//Enlaza offset a html y css | ||
let number_offset = document.getElementById("offset_ci").value; | ||
document.getElementById("msg-encode-check").innerHTML = window.cipher.encode(textEncode, number_offset); | ||
}); | ||
|
||
|
||
/*pantalla descifrado*/ | ||
|
||
const descifrado = document.getElementById("page-decode");//se liga a href | ||
|
||
descifrado.addEventListener("click", function() { | ||
document.getElementById("text-decode").style.display = "none"; | ||
document.getElementById("text-decode").style.display = "block"; | ||
document.getElementById("text-encode").style.display = "none"; | ||
}); | ||
|
||
/*variables para funcionamiento de botones descifrar*/ | ||
|
||
const btnTextDecode = document.getElementById("btn_decode"); | ||
btnTextDecode.addEventListener("click", function() { | ||
//enlaza a caja de texto html y css | ||
let textDecode = document.getElementById("box-msg-decode").value; | ||
//Enlaza offset a html y css | ||
let number_offset = document.getElementById("offset_des").value; | ||
document.getElementById("msg-decode-check").innerHTML = window.cipher.decode(textDecode, number_offset); | ||
}); | ||
|
||
} |
Oops, something went wrong.
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.
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.
En general todo muy bien, cuida tu indentación!