-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogEncriptador.js
39 lines (34 loc) · 1.27 KB
/
logEncriptador.js
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
const btnEncriptar = document.getElementById('btnEncriptar');
const btnDesencriptar = document.getElementById('btnDesencriptar');
const texto = document.getElementById('txtTexto');
const panelInicio = document.getElementById('inicio');
const respuesta = document.getElementById('respuesta');
const btnCopiar = document.getElementById('btnCopiar');
function encriptar(texto) {
return texto.replaceAll("e","enter").replaceAll("i","imes").replaceAll("a","ai")
.replaceAll("o","ober").replaceAll("u","ufat");
}
function desencriptar(texto) {
return texto.replaceAll("enter","e").replaceAll("imes","i").replaceAll("ai","a")
.replaceAll("ober","o").replaceAll("ufat","u");
}
btnEncriptar.onclick = ()=>{
panelInicio.classList.add('hidden-s');
respuesta.classList.remove('hidden-s');
btnCopiar.classList.remove('hidden-s');
respuesta.value = encriptar(texto.value);
texto.value = "";
}
btnDesencriptar.onclick = ()=>{
panelInicio.classList.add('hidden-s');
respuesta.classList.remove('hidden-s');
btnCopiar.classList.remove('hidden-s');
respuesta.value = desencriptar(texto.value);
texto.value = "";
}
btnCopiar.onclick = ()=>{
respuesta.focus();
document.execCommand('selectAll');
document.execCommand('copy');
texto.focus()
}