-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
94 lines (60 loc) · 2.06 KB
/
main.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var botaoCriptografar = document.querySelector("#botaoCriptografar");
var botaoDecriptografar = document.querySelector("#botaoDecriptografar");
var caixaTextoMensagemCriptografada = document.querySelector("#mensagemCriptografada");
var botaoCopiar = document.querySelector("#botaoCopiar");
var tituloDireita = document.querySelector("#titulo-mensagem");
botaoCriptografar.addEventListener("click", criptografrar);
botaoDecriptografar.addEventListener("click", decriptografar);
botaoCopiar.addEventListener("click",copiar);
function criptografrar() {
var caixaTextoMensagem = document.querySelector("#mensagem");
var caixaDeTexto = caixaTextoMensagem.value;
var texto = caixaDeTexto.split("");
for(i=0; i<texto.length; i++){
if(texto[i]=="a"){
texto[i] = "ai";
}
if(texto[i]=="e"){
texto[i] = "enter";
}
if(texto[i]=="u"){
texto[i] = "ufat";
}
if(texto[i]=="i"){
texto[i] = "imes";
}
if(texto[i]=="o"){
texto[i] = "ober";
}
}
var novoTexto = texto.join("");
caixaTextoMensagemCriptografada.value = novoTexto;
caixaTextoMensagem.value = "";
tituloDireita.innerHTML = "Mensagem Criptografada";
}
function decriptografar() {
var caixaTextoMensagem = document.querySelector("#mensagem");
var texto = caixaTextoMensagem.value;
letras = texto.split("");
var novoTexto = texto.replaceAll("ai","a");
novoTexto = novoTexto.replaceAll("enter","e");
novoTexto = novoTexto.replaceAll("ufat","u");
novoTexto = novoTexto.replaceAll("imes","i");
novoTexto = novoTexto.replaceAll("ober","o");
caixaTextoMensagemCriptografada.value = novoTexto;
caixaTextoMensagem.value = "";
tituloDireita.innerHTML = "Mensagem Decriptografada";
}
function copiar() {
var caixaTextoMensagem = document.querySelector("#mensagem");
var caixaTextoMensagemCriptografada = document.querySelector("#mensagemCriptografada");
var texto = caixaTextoMensagemCriptografada.value;
navigator.clipboard.writeText(texto);
caixaTextoMensagemCriptografada.value="";
caixaTextoMensagem.value = "";
}
// a = ai
// e = enter
// u = ufat
// i = imes
// o = ober