-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
110 lines (90 loc) · 3.37 KB
/
script.js
File metadata and controls
110 lines (90 loc) · 3.37 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function codificarTexto() {
try {
var texto = document.getElementById('inputText').value;
var textoCodificado = btoa(texto);
document.getElementById('resultMessage').innerText = textoCodificado;
document.getElementById('textoStatus').innerText = " Texto criptografado:";
document.getElementById('inputText').value = "";
} catch (error) {
document.getElementById('resultMessage').innerText = "Erro ao codificar o texto.";
console.error("Erro ao codificar o texto:", error);
}
}
function descodificarTexto() {
try {
var texto = document.getElementById('inputText').value;
var textoDecodificado = atob(texto);
document.getElementById('resultMessage').innerText = textoDecodificado;
document.getElementById('textoStatus').innerText = " Texto descriptografado:";
document.getElementById('inputText').value = "";
} catch (error) {
document.getElementById('resultMessage').innerText = "Erro ao decodificar o texto.";
console.error("Erro ao decodificar o texto:", error);
}
}
function copy() {
try {
var resultTextElement = document.getElementById('resultMessage');
var textArea = document.createElement('textarea');
textArea.value = resultTextElement.innerText;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
console.log("Texto copiado para a Área de Transferência.");
} catch (error) {
console.error("Erro ao copiar para a Área de Transferência:", error);
}
}
//codigo pra implementações futuras de novos metodos de criptografia
function encode(text, algorithm) {
if (algorithm === 'base64') {
return btoa(text);
} else if (algorithm === 'sha256') {
} else if (algorithm === 'md5') {
}
return '';
}
//codigo pra implementações futuras de novos metodos de criptografia
function decode(encodedText, algorithm) {
if (algorithm === 'base64') {
return atob(encodedText);
} else if (algorithm === 'sha256') {
} else if (algorithm === 'md5') {
}
return '';
}
//codigo pra implementações futuras de novos metodos de criptografia
function rot13(text) {
return text.replace(/[a-zA-Z]/g, function (char) {
var offset = char <= 'Z' ? 65 : 97;
return String.fromCharCode((char.charCodeAt(0) - offset + 13) % 26 + offset);
});
}
//codigo pra implementações futuras de novos metodos de criptografia
function hexEncode(text) {
return text.split('').map(function (char) {
return char.charCodeAt(0).toString(16);
}).join('');
}
//codigo pra implementações futuras de novos metodos de criptografia
function base32Encode(text) {
let binaryString = '';
for (let i = 0; i < text.length; i++) {
const binaryChar = text[i].charCodeAt(0).toString(2).padStart(8, '0');
binaryString += binaryChar;
}
let encoded = '';
for (let i = 0; i < binaryString.length; i += 5) {
const chunk = binaryString.substr(i, 5).padEnd(5, '0');
encoded += base32Chars[parseInt(chunk, 2)];
}
return encoded;
}
function urlEncode(text) {
return encodeURIComponent(text);
}
//codigo pra implementações futuras de novos metodos de criptografia
function urlEncode(text) {
return encodeURIComponent(text);
}