-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
42 lines (39 loc) · 1.23 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
function criptografar() {
var str = document.getElementById("inputTexto").value
var cipher = []
for (var i = 0; i < str.length; i++) {
cipher[i] = str.charCodeAt(i) + 3
}
document.getElementById("mensagem").value = String.fromCharCode.apply(
null,
cipher
)
document.getElementById("btn-copiar").disabled = false
document.getElementById("btn-limpar").disabled = false
}
function descriptografar() {
var str = document.getElementById("mensagem").value
var cipher = []
for (var i = 0; i < str.length; i++) {
cipher[i] = str.charCodeAt(i) - 3
}
document.getElementById("inputTexto").value = String.fromCharCode.apply(
null,
cipher
)
document.getElementById("btn-copiar").disabled = false
document.getElementById("btn-limpar").disabled = false
}
function copiar() {
var copyText = document.getElementById("mensagem")
copyText.select()
copyText.setSelectionRange(0, 99999)
document.execCommand("copy")
alert("Texto copiado para a área de transferência!")
}
function limpar() {
document.getElementById("inputTexto").value = ""
document.getElementById("mensagem").value = ""
document.getElementById("btn-copiar").disabled = true
document.getElementById("btn-limpar").disabled = true
}