-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion-final.html
147 lines (129 loc) · 3.92 KB
/
version-final.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html>
<head>
<title>Encriptador de Texto</title>
<style>
body {
background-color: black;
font-family: Tahoma;
color: skyblue;
}
#container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
h1 {
text-align: center;
}
label {
display: block;
margin-top: 20px;
}
input[type="text"] {
width: 300px;
padding: 5px;
}
button {
padding: 8px 16px;
margin-top: 20px;
}
#result {
margin-top: 20px;
border: 1px solid skyblue;
padding: 10px;
width: 300px;
}
</style>
</head>
<body>
<div id="container">
<h1>Encriptador de Texto</h1>
<div id="encrypt">
<h3>Encriptar</h3>
<label for="encryptInput">Texto a encriptar:</label>
<input type="text" id="encryptInput">
<button onclick="encrypt()">Encriptar</button>
</div>
<div id="decrypt">
<h3>Desencriptar</h3>
<label for="decryptInput">Texto a desencriptar:</label>
<input type="text" id="decryptInput">
<button onclick="decrypt()">Desencriptar</button>
</div>
<div id="result">
<h3>Resultado</h3>
<p id="output"></p>
<button onclick="copyResult()">Copiar</button>
</div>
</div>
<script>
function encrypt() {
var input = document.getElementById('encryptInput').value;
var result = "";
for (var i = 0; i < input.length; i++) {
var char = input.charAt(i);
switch (char) {
case "e":
result += "enter";
break;
case "i":
result += "imes";
break;
case "a":
result += "ai";
break;
case "o":
result += "ober";
break;
case "u":
result += "ufat";
break;
default:
result += char;
}
}
document.getElementById('output').innerText = result;
}
function decrypt() {
var input = document.getElementById('decryptInput').value;
var result = "";
var i = 0;
while (i < input.length) {
var char = input.charAt(i);
if (char === "e" && input.substr(i, 5) === "enter") {
result += "e";
i += 5;
} else if (char === "i" && input.substr(i, 4) === "imes") {
result += "i";
i += 4;
} else if (char === "a" && input.substr(i, 2) === "ai") {
result += "a";
i += 2;
} else if (char === "o" && input.substr(i, 4) === "ober") {
result += "o";
i += 4;
} else if (char === "u" && input.substr(i, 4) === "ufat") {
result += "u";
i += 4;
} else {
result += char;
i++;
}
}
document.getElementById('output').innerText = result;
}
function copyResult() {
var result = document.getElementById('output').innerText;
var tempInput = document.createElement("textarea");
tempInput.value = result;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
}
</script>
</body>
</html>