-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (38 loc) · 1.36 KB
/
script.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
40
41
42
document.addEventListener("DOMContentLoaded", function () {
document
.getElementById("criptografarBtn")
.addEventListener("click", function () {
const texto = document.getElementById("inputText").value;
const textoCriptografado = criptografarTexto(texto);
document.getElementById("outputText").value = textoCriptografado;
});
document
.getElementById("descriptografarBtn")
.addEventListener("click", function () {
const textoCriptografado = document.getElementById("inputText").value;
const textoOriginal = descriptografarTexto(textoCriptografado);
document.getElementById("outputText").value = textoOriginal;
});
document.getElementById("copiarBtn").addEventListener("click", function () {
const texto = document.getElementById("outputText");
texto.select();
document.execCommand("copy");
alert("Texto copiado para a área de transferência!");
});
});
function criptografarTexto(texto) {
return texto
.replace(/e/g, "enter")
.replace(/i/g, "imes")
.replace(/a/g, "ai")
.replace(/o/g, "ober")
.replace(/u/g, "ufat");
}
function descriptografarTexto(textoCriptografado) {
return textoCriptografado
.replace(/enter/g, "e")
.replace(/imes/g, "i")
.replace(/ai/g, "a")
.replace(/ober/g, "o")
.replace(/ufat/g, "u");
}