-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (60 loc) · 1.93 KB
/
script.js
File metadata and controls
71 lines (60 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const entradaTexto = document.querySelector(".entradaTexto");
const mensaje = document.querySelector(".mensaje");
let palabrasClave = [["e","enter"],
["i","imes"],
["a","ai"],
["o","ober"],
["u","ufat"]];
function encriptar(stringEncriptado){
stringEncriptado = stringEncriptado.toLowerCase();
if(stringEncriptado.trim() != "")
{
for(let i=0; i<palabrasClave.length; i++)
{
if(stringEncriptado.includes(palabrasClave[i][0]))
{
stringEncriptado=stringEncriptado.replaceAll(palabrasClave[i][0],palabrasClave[i][1]);
}
}
}
else{
return "Ingrese un texto para encriptar";
}
return stringEncriptado;
}
function btnEncriptar()
{
const textoEncriptado = encriptar(entradaTexto.value);
mensaje.value = textoEncriptado;
mensaje.style.backgroundImage = "none";
entradaTexto.value = "";
}
function desencriptar(stringDesencriptado){
stringDesencriptado = stringDesencriptado.toLowerCase();
if(stringDesencriptado.trim() != "") //Verifica que el contenido del textarea no este vacio
{
for(let i=0; i<palabrasClave.length; i++)
{
if(stringDesencriptado.includes(palabrasClave[i][1]))
{
stringDesencriptado=stringDesencriptado.replaceAll(palabrasClave[i][1],palabrasClave[i][0]);
}
}
}
else{
return "Ingrese un texto para desencriptar";
}
return stringDesencriptado;
}
function btnDesencriptar(){
const textoEncriptado = desencriptar(entradaTexto.value);
mensaje.value = textoEncriptado;
mensaje.style.backgroundImage = "none";
entradaTexto.value = "";
}
function btnCopiar()
{
mensaje.select();
navigator.clipboard.writeText(mensaje.value).then(() => alert("Texto copiado"));
mensaje.value = "";
}