-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
223 lines (215 loc) · 6.54 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Picocrypt</title>
<meta charset="UTF-8">
<meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/key.svg">
<style>
@font-face{
font-family:"Inter";
src:url("/inter.woff2");
font-weight:400;
font-style:normal;
font-display:swap;
}
*{
-webkit-tap-highlight-color:transparent;
user-select:none;
}
body{
position:absolute;
top:0;
left:0;
width:100vw;
height:100vh;
overflow:hidden;
margin:0;
display:flex;
align-items:center;
justify-content:center;
background-color:#20242c;
color:#f5deb3;
font-family:"Inter";
}
body > div > div{
width:300px;
height:100px;
display:flex;
align-items:center;
justify-content:center;
box-sizing:border-box;
margin-bottom:12px;
background-color:#30343c;
border-radius:6px;
font-size:17px;
cursor:pointer;
}
body > div > div > p{
text-overflow:ellipsis;
white-space:nowrap;
overflow:hidden;
width:80%;
text-align:center;
}
input[type="password"]{
width:300px;
height:32px;
box-sizing:border-box;
padding:4px;
padding-left:8px;
padding-right:8px;
margin-bottom:12px;
border:none;
border-radius:6px;
outline:none;
background-color:#30343c;
color:#f5deb3;
font-size:16px;
font-family:inherit;
}
input[type="password"]::placeholder{
color:#f5deb347;
}
input[type="submit"]{
width:300px;
height:32px;
margin-bottom:6px;
border:none;
border-radius:6px;
outline:none;
background-color:#30343c;
color:#f5deb3;
font-size:16px;
font-family:inherit;
cursor:pointer;
}
.disabled{
opacity:0.3;
pointer-events:none;
}
</style>
<script src="/wasm_exec.min.js"></script>
</head>
<body>
<input id="fin" type="file" style="display:none;">
<div>
<div><p>Click here to select a file.</p></div>
<input type="password" id="password" class="disabled" placeholder="Password" autocomplete="off"><br>
<input type="password" id="cpassword" class="disabled" placeholder="Confirm" autocomplete="off"><br>
<input type="submit" id="start" class="disabled" value="Start">
<input type="submit" id="work" style="display:none;">
<p id="status" class="disabled" style="margin:0;font-size:16px;">Ready.</p>
</div>
<script>
(() => {
"use strict";
if (!WebAssembly || !WebAssembly.instantiateStreaming || !window.crypto || !window.crypto.getRandomValues) {
document.body.innerHTML = "<h1>Unsupported browser!</h1>";
}
})();
</script>
<script>
(()=>{
"use strict";
document.querySelector("body > div > div").onclick = ()=>{
document.getElementById("fin").click();
};
document.getElementById("fin").onchange = function(){
if(this.files.length>0){
if (this.files[0].size > 1073741824) { // 1 GiB
document.getElementById("status").innerHTML = "File must be less than 1 GiB!";
document.getElementById("status").style.color = "#db2828";
setTimeout(() => {
window.location.reload();
}, 3000);
return;
}
document.querySelector("body > div > div > p").innerHTML = this.files[0].name;
if(this.files[0].name.endsWith(".pcv")){
document.getElementById("start").value = "Decrypt";
}else{
document.getElementById("start").value = "Encrypt";
}
document.getElementById("password").classList.remove("disabled");
document.getElementById("cpassword").classList.remove("disabled");
}else{
window.location.reload();
}
};
document.getElementById("password").oninput = ()=>{
var pwd = document.getElementById("password").value;
if(pwd&&pwd==document.getElementById("cpassword").value){
document.getElementById("start").classList.remove("disabled");
document.getElementById("status").classList.remove("disabled");
}else{
document.getElementById("start").classList.add("disabled");
document.getElementById("status").classList.add("disabled");
}
};
document.getElementById("cpassword").oninput = document.getElementById("password").oninput;
document.getElementById("start").onclick = ()=>{
document.querySelector("body > div > div").classList.add("disabled");
document.getElementById("password").classList.add("disabled");
document.getElementById("cpassword").classList.add("disabled");
document.getElementById("start").classList.add("disabled");
document.getElementById("status").innerHTML = "Working...";
document.getElementById("status").style.color = "#f5deb3";
setTimeout(()=>{
document.getElementById("work").click();
},100);
};
window.download = data=>{
if(data.length==1){
document.querySelector("body > div > div").classList.remove("disabled");
document.getElementById("password").classList.remove("disabled");
document.getElementById("cpassword").classList.remove("disabled");
document.getElementById("start").classList.remove("disabled");
switch(data[0]){
case 1:
document.getElementById("status").innerHTML = "Unsupported volume.";
break;
case 2:
document.getElementById("status").innerHTML = "Corrupted header.";
break;
case 3:
document.getElementById("status").innerHTML = "Incorrect password.";
break;
case 4:
document.getElementById("status").innerHTML = "Data is modified.";
break;
case 5:
document.getElementById("status").innerHTML = "Unable to generate random values.";
break;
}
document.getElementById("status").style.color = "#db2828";
return;
}
const a = document.createElement("a");
a.href = URL.createObjectURL(new Blob([data.slice(1)]));
a.download = document.getElementById("fin").files[0].name;
if(a.download.endsWith(".pcv")){
a.download = a.download.replace(".pcv","");
}else{
a.download = a.download+".pcv";
}
a.style.display = "none";
document.body.appendChild(a);
a.click();
a.remove();
document.querySelector("body > div > div > p").innerHTML = "Click here to select a file.";
document.getElementById("password").value = "";
document.getElementById("cpassword").value = "";
document.getElementById("status").innerHTML = "Completed.";
document.getElementById("status").style.color = "#44b944";
setTimeout(()=>{
window.location.reload();
},3000);
};
})();
const go = new Go();
WebAssembly.instantiateStreaming(fetch("/main.wasm"), go.importObject).then(result => go.run(result.instance));
</script>
</body>
</html>