-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (60 loc) · 1.87 KB
/
script.js
File metadata and controls
70 lines (60 loc) · 1.87 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
const textArea = document.querySelector(".text-area");
const mensaje = document.querySelector(".mensaje");
function btnEncriptar() {
const textoEncriptado = encriptar(textArea.value);
const informacion = document.querySelector('.informacion');
const imagenInfo = document.querySelector('.imagen-info');
const btnCopiar = document.querySelector('.btn-copiar');
mensaje.value = textoEncriptado;
textArea.value ="";
mensaje.style.backgroundImage = "none";
imagenInfo.style.display = "none";
btnCopiar.style.display = 'block';
}
function encriptar(stringEncriptada) {
let matrizCodigo = [
["e", "enter"],
["i", "imes"],
["a", "ai"],
["o", "ober"],
["u", "ufat"],
];
stringEncriptada = stringEncriptada.toLowerCase();
for (let i = 0; i < matrizCodigo.length; i++) {
if (stringEncriptada.includes(matrizCodigo[i][0])) {
stringEncriptada = stringEncriptada.replaceAll(
matrizCodigo[i][0],
matrizCodigo[i][1]
);
}
}
return stringEncriptada;
}
function btnDesencriptar() {
const textoEncriptado = desencriptar(textArea.value);
mensaje.value = textoEncriptado;
textArea.value ="";
mensaje.style.backgroundImage = "none";
}
function desencriptar(stringDesencriptada) {
let matrizCodigo = [
["e", "enter"],
["i", "imes"],
["a", "ai"],
["o", "ober"],
["u", "ufat"],
];
stringDesencriptada = stringDesencriptada.toLowerCase();
for (let i = 0; i < matrizCodigo.length; i++) {
if (stringDesencriptada.includes(matrizCodigo[i][1])) {
stringDesencriptada = stringDesencriptada.replaceAll(
matrizCodigo[i][1],
matrizCodigo[i][0]
);
}
}
return stringDesencriptada;
}
function copiarMensaje() {
textArea.value = mensaje.value;
}