-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesajpar.html
237 lines (209 loc) · 6.35 KB
/
mesajpar.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<title>ŞİFRELEME</title>
<style type="text/css">
body {
background-color: black;
}
::selection {
background: darkgrey;
color: black;
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: lightgreen;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
box-shadow: 0 0 5px black;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
#usta{
color: black;
font-size: 150px;
text-shadow: 0 0 10px white;
margin-top: -10px;
text-align: center;
}
#main {
margin-top: -150px;
margin-left: 30px;
text-align: center;
}
#secenek{
color: #2196F3;
margin-top: 38px;
margin-left: 10px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#uyari{
color: red;
font-size: 22px;
margin-top: 10px;
text-shadow: 0 0 12px red;
}
</style>
</head>
<body>
<input type="text" id="metot" value="varsayilan" style="width:300px; height: 45px; font-size: 25px; text-align: center; background-color: black; color: white; border: 1px solid white;" autofocus value="value text" onfocus="var temp_value=this.value; this.value=''; this.value=temp_value;">
<label class="switch" style="top: 20px; left: 10px; cursor: pointer;">
<p id="secenek">Metin</p>
<input type="checkbox" id="cek" checked style="display: none;" onclick="sec()">
<span class="slider round" style="z-index: -1;"></span>
</label>
<p id="usta">USTA</p>
<div id="main">
<p style="color: #2196F3; font-size: 20px;">Metin</p>
<textarea id="metin" style="width:400px; height: 150px; font-size: 20px; text-align: center;">metin metin</textarea>
<p style="color: lightgreen; font-size: 20px;">Şifre</p>
<textarea id="sifre" style="display: inline-block;width:400px; height: 150px;font-size: 20px; text-align: center;"></textarea><br>
<p id="uyari">HATA !!!</p>
</div>
<script>
var metot = document.getElementById('metot');
var secenek = document.getElementById('secenek');
var usta = document.getElementById('usta');
var metin = document.getElementById('metin');
var sifre = document.getElementById('sifre');
var uyari = document.getElementById('uyari');
metot.spellcheck = false;
metin.spellcheck = false;
sifre.spellcheck = false;
function sifrele(salt, text) {
var textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
var byteHex = (n) => ("0" + Number(n).toString(16)).substr(-2);
var applySaltToChar = (code) => textToChars(salt).reduce((a, b) => a ^ b, code);
sifre.value = text.split("").map(textToChars).map(applySaltToChar).map(byteHex).join("");
}
function donustur(salt, encoded) {
var textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
var applySaltToChar = (code) => textToChars(salt).reduce((a, b) => a ^ b, code);
metin.value = encoded.match(/.{1,2}/g).map((hex) => parseInt(hex, 16)).map(applySaltToChar).map((charCode) => String.fromCharCode(charCode)).join("");
}
function test(salt, encoded) {
var textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
var applySaltToChar = (code) => textToChars(salt).reduce((a, b) => a ^ b, code);
uyari.innerHTML = encoded.match(/.{1,2}/g).map((hex) => parseInt(hex, 16)).map(applySaltToChar).map((charCode) => String.fromCharCode(charCode)).join("");
}
function test2(salt, text) {
var textToChars = (text) => text.split("").map((c) => c.charCodeAt(0));
var byteHex = (n) => ("0" + Number(n).toString(16)).substr(-2);
var applySaltToChar = (code) => textToChars(salt).reduce((a, b) => a ^ b, code);
uyari.innerHTML = text.split("").map(textToChars).map(applySaltToChar).map(byteHex).join("");
}
function sec() {
if (cek.checked == true){
secenek.innerHTML = "Metin";
secenek.style.color = "#2196F3";
sifrele(metot.value, metin.value);
test(metot.value, sifre.value);
kontrol();
} else {
secenek.innerHTML = "Şifre";
secenek.style.color = "lightgreen";
donustur(metot.value, sifre.value);
test2(metot.value, metin.value);
kontrol2();
}
metot.focus();
}
function kontrol() {
if (uyari.innerHTML == metin.value){
uyari.style.visibility = "hidden";
usta.innerHTML = "USTA";
usta.style.color = "black";
usta.style.textShadow = "0 0 10px white";
} else {
uyari.innerHTML = "Türkçe karekter kullanıldı !!!";
uyari.style.visibility = "visible";
usta.innerHTML = "HATA";
usta.style.color = "red";
usta.style.textShadow = "0 0 10px black";
}
}
function kontrol2() {
if (uyari.innerHTML == sifre.value){
uyari.style.visibility = "hidden";
usta.innerHTML = "USTA";
usta.style.color = "black";
usta.style.textShadow = "0 0 10px white";
} else {
uyari.innerHTML = "Türkçe karekter kullanıldı !!!";
uyari.style.visibility = "visible";
usta.innerHTML = "HATA";
usta.style.color = "red";
usta.style.textShadow = "0 0 10px black";
}
}
sec();
sifrele(metot.value, metin.value);
test(metot.value, sifre.value);
kontrol();
metin.addEventListener("input", function() {
sifrele(metot.value, metin.value);
test(metot.value, sifre.value);
kontrol();
});
sifre.addEventListener("input", function() {
donustur(metot.value, sifre.value);
test2(metot.value, metin.value);
kontrol2();
});
metot.addEventListener("input", function() {
if (cek.checked == true){
sifrele(metot.value, metin.value);
test(metot.value, sifre.value);
kontrol();
} else {
donustur(metot.value, sifre.value);
test2(metot.value, metin.value);
kontrol2();
}
});
</script>
</body>
</html>