-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
166 lines (149 loc) · 6.01 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Encryption / Java Decryption</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">
if (window.location.protocol === "http:" && window.location.hostname !== "localhost") {
window.location.replace(window.location.href.replace("http:", "https:"));
}
</script>
<script type="k11-script" id="k11_script"></script>
<link rel="icon" sizes="192x192" href="//www.kcak11.com/assets/images/the-k-circle_192x192.png" />
<link rel="apple-touch-icon" sizes="128x128" href="//www.kcak11.com/assets/images/the-k-circle_128x128.png" />
<link href='//www.kcak11.com/favicon.png' rel='icon' type='image/x-icon' />
<meta content="https://cdn.kcak11.com/profile/the-k-circle.png" itemprop="image" />
<meta name="theme-color" content="#5aa0d3" />
<style type="text/css">
body {
font-family: Verdana;
font-size: 14px;
padding: 30px;
}
.visibilityHidden {
visibility: hidden;
}
.mainWrapper {
min-width: 1250px;
}
h1 {
margin-bottom: 50px;
}
.inputMessage {
width: 700px;
}
.encryptedPayload,
.decryptedResponse,
.waitMsg {
display: block;
margin-top: 30px;
display: none;
}
.waitMsg {
color: #00f;
font-weight: bold;
font-size: 16px;
}
.encryptedPayload textarea,
.decryptedResponse textarea {
width: 1000px;
height: 200px;
resize: none;
}
input,
textarea {
outline: none;
border: 1px solid #000;
padding: 5px;
}
button {
padding: 5px;
border: 1px solid #000;
background-color: #00f;
color: #fff;
}
.sourcesInfo {
margin-top: 30px;
}
span[linkhref] {
color: #00f;
cursor: pointer;
}
</style>
</head>
<body class="visibilityHidden">
<div class="mainWrapper">
<h1>JavaScript Client Encryption / Backend Decryption</h1>
<form id="jsForm">
<span>Enter message:</span>
<input class="inputMessage" type="text" id="message-input" placeholder="<Provide a message that you want to securely transmit to the server>" autocomplete="off" spellcheck="false" />
<button type="submit">Encrypt and Submit</button>
<br />
<div class="encryptedPayload">
<div>Payload:</div>
<textarea readonly="true" id="encrypted-result" autocomplete="off" spellcheck="false"></textarea>
</div>
<div class="waitMsg">Please wait . . .</div>
<div class="decryptedResponse">
<div>Response:</div>
<textarea readonly="true" id="decrypted-result" autocomplete="off" spellcheck="false"></textarea>
</div>
</form>
</div>
<script type="text/javascript">
((function () {
document.getElementById("jsForm").addEventListener("submit", function (e) {
e.preventDefault();
doSubmit();
}, false);
function doEncryptAndSend() {
if (!document.getElementById("message-input").value) {
document.querySelector(".waitMsg").style.display = "none";
return;
}
var encrypt = new EncryptUtil();
var encryptedMessage = encrypt.doEncrypt(document.getElementById("message-input").value);
var payload = {};
payload["encryptedMessage"] = encryptedMessage;
document.getElementById("encrypted-result").value = JSON.stringify(payload, null, 4);
document.querySelector(".encryptedPayload").style.display = "block";
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById("decrypted-result").value = JSON.stringify(JSON.parse(this.responseText), null, 4);
document.querySelector(".waitMsg").style.display = "none";
document.querySelector(".decryptedResponse").style.display = "block";
document.getElementById("message-input").focus();
}
});
xhr.open("POST", "https://api.kcak11.com/Crypto", true);
xhr.setRequestHeader("Content-Type", "application/json");
document.querySelector(".decryptedResponse").style.display = "none";
document.querySelector(".waitMsg").style.display = "block";
xhr.send(JSON.stringify(payload));
}
function doSubmit() {
document.querySelector(".waitMsg").style.display = "block";
doEncryptAndSend();
}
var scr = document.createElement("script");
scr.type = "text/javascript";
scr.src = "js/encrypt.min.js?_req=" + ("abcdef0123456789".split("").sort(function () { return Math.random() - Math.random(); }).join(""));
var _scr = document.getElementById("k11_script");
_scr.parentNode.replaceChild(scr, _scr);
var _chk = function () {
if (window.EncryptUtil) {
document.querySelector("body").classList.remove("visibilityHidden");
document.getElementById("message-input").focus();
setTimeout(function () {
document.getElementById("message-input").value = "";
}, 10);
} else {
setTimeout(_chk, 50);
}
};
_chk();
})());
</script>
</body>
</html>