-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
57 lines (42 loc) · 1.59 KB
/
Copy pathscript.js
File metadata and controls
57 lines (42 loc) · 1.59 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
const inputTexto = document.querySelector(".texto");
const mensaje = document.querySelector(".mensajes");
function btnEncriptar(){
const textoEncriptado = encriptar(inputTexto.value);
mensaje.value = textoEncriptado;
mensaje.style.background ="#E09FA8";
inputTexto.value = "";
}
function btnDesencriptar(){
const textoDesenctiptado = desencriptar(inputTexto.value);
mensaje.value = textoDesenctiptado;
mensaje.style.background = "#E09FA8";
inputTexto.value = "";
}
function encriptar(stringEncriptado){
let matriz = [["e","enter"], ["i","imes"],["a","ai"],["o","ober"],["u","ufat"]];
stringEncriptado = stringEncriptado.toLowerCase();
for(let i = 0; i < matriz.length; i++){
if(stringEncriptado.includes(matriz[i][0])){
stringEncriptado = stringEncriptado.replaceAll(matriz[i][0],matriz[i][1]);
}
}
return stringEncriptado;
}
function desencriptar(stringDesencriptado){
let matriz = [["e","enter"],["i","imes"],["a","ai"],["o","ober"],["u","ufat"]];
stringDesencriptado = stringDesencriptado.toLowerCase();
for(let i = 0; i < matriz.length; i++){
if(stringDesencriptado.includes(matriz[i][1])){
stringDesencriptado =stringDesencriptado.replaceAll(matriz[i][1],matriz[i][0]);
}
}
return stringDesencriptado;
}
function copiar(){
mensaje.select();
navigator.clipboard.writeText(mensaje.value);
mensaje.value = "";
mensaje.style.background = "#E09FA8;";
mensaje.style.backgroundImage = "url('images/lock.png')";
mensaje.style.backgroundSize = "100% 100%";
}