-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
263 lines (225 loc) · 10.8 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Hash Calculator</title>
<style>
body {
background-color: #0a0a0a;
color: #00ff00;
font-family: 'Courier New', monospace;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background-color: #1a1a1a;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
max-width: 600px;
width: 100%;
position: relative;
}
.cursor-tag {
position: absolute;
top: -15px;
right: -15px;
background: #00ff00;
color: #000;
padding: 5px 10px;
border-radius: 5px;
font-size: 0.8em;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
transform: rotate(5deg);
z-index: 100;
}
h1 {
text-align: center;
margin-bottom: 30px;
text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}
.upload-area {
border: 2px dashed #00ff00;
padding: 20px;
text-align: center;
margin-bottom: 20px;
cursor: pointer;
transition: all 0.3s ease;
}
.upload-area:hover {
background-color: rgba(0, 255, 0, 0.1);
}
.result {
background-color: #000;
padding: 15px;
border-radius: 5px;
margin-top: 20px;
display: none;
}
.hash {
word-break: break-all;
font-size: 0.9em;
margin-top: 10px;
}
.filename {
color: #00cc00;
margin-bottom: 5px;
}
.loading {
display: none;
text-align: center;
margin: 20px 0;
}
.progress-container {
margin-top: 10px;
background: #000;
border: 1px solid #00ff00;
height: 20px;
width: 100%;
position: relative;
}
.progress-bar {
height: 100%;
width: 0;
background-color: #00ff00;
transition: width 0.3s ease;
}
.progress-text {
position: absolute;
width: 100%;
text-align: center;
color: #fff;
font-size: 0.8em;
line-height: 20px;
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0; }
100% { opacity: 1; }
}
.blink {
animation: blink 1s infinite;
}
#file-input {
display: none;
}
.error {
color: #ff0000;
margin-top: 10px;
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="cursor-tag">Made with Cursor in <10min</div>
<h1>[ FILE HASH CALCULATOR ]</h1>
<div class="upload-area" id="drop-zone">
<p>DROP FILE HERE</p>
<p>or</p>
<p>CLICK TO SELECT</p>
</div>
<input type="file" id="file-input">
<div class="loading">
<p class="blink">CALCULATING HASH...</p>
<div class="progress-container">
<div class="progress-bar"></div>
<div class="progress-text">0%</div>
</div>
</div>
<div class="error">
ERROR PROCESSING FILE
</div>
<div class="result">
<div class="filename"></div>
<div class="hash"></div>
</div>
</div>
<script>
// MD5 implementation
function MD5(d){var r = M(V(Y(X(d),8*d.length)));return r.toLowerCase()};function M(d){for(var _,m="0123456789ABCDEF",f="",r=0;r<d.length;r++)_=d.charCodeAt(r),f+=m.charAt(_>>>4&15)+m.charAt(15&_);return f}function X(d){for(var _=Array(d.length>>2),m=0;m<_.length;m++)_[m]=0;for(m=0;m<8*d.length;m+=8)_[m>>5]|=(255&d.charCodeAt(m/8))<<m%32;return _}function V(d){for(var _="",m=0;m<32*d.length;m+=8)_+=String.fromCharCode(d[m>>5]>>>m%32&255);return _}function Y(d,_){d[_>>5]|=128<<_%32,d[14+(_+64>>>9<<4)]=_;for(var m=1732584193,f=-271733879,r=-1732584194,i=271733878,n=0;n<d.length;n+=16){var h=m,t=f,g=r,e=i;f=md5_ii(f=md5_ii(f=md5_ii(f=md5_ii(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_hh(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_gg(f=md5_ff(f=md5_ff(f=md5_ff(f=md5_ff(f,r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+0],7,-680876936),f,r,d[n+1],12,-389564586),m,f,d[n+2],17,606105819),i,m,d[n+3],22,-1044525330),r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+4],7,-176418897),f,r,d[n+5],12,1200080426),m,f,d[n+6],17,-1473231341),i,m,d[n+7],22,-45705983),r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+8],7,1770035416),f,r,d[n+9],12,-1958414417),m,f,d[n+10],17,-42063),i,m,d[n+11],22,-1990404162),r=md5_ff(r,i=md5_ff(i,m=md5_ff(m,f,r,i,d[n+12],7,1804603682),f,r,d[n+13],12,-40341101),m,f,d[n+14],17,-1502002290),i,m,d[n+15],22,1236535329),r=md5_gg(r,i=md5_gg(i,m=md5_gg(m,f,r,i,d[n+1],5,-165796510),f,r,d[n+6],9,-1069501632),m,f,d[n+11],14,643717713),i,m,d[n+0],20,-373897302),r=md5_gg(r,i=md5_gg(i,m=md5_gg(m,f,r,i,d[n+5],5,-701558691),f,r,d[n+10],9,38016083),m,f,d[n+15],14,-660478335),i,m,d[n+4],20,-405537848),r=md5_gg(r,i=md5_gg(i,m=md5_gg(m,f,r,i,d[n+9],5,568446438),f,r,d[n+14],9,-1019803690),m,f,d[n+3],14,-187363961),i,m,d[n+8],20,1163531501),r=md5_gg(r,i=md5_gg(i,m=md5_gg(m,f,r,i,d[n+13],5,-1444681467),f,r,d[n+2],9,-51403784),m,f,d[n+7],14,1735328473),i,m,d[n+12],20,-1926607734),r=md5_hh(r,i=md5_hh(i,m=md5_hh(m,f,r,i,d[n+5],4,-378558),f,r,d[n+8],11,-2022574463),m,f,d[n+11],16,1839030562),i,m,d[n+14],23,-35309556),r=md5_hh(r,i=md5_hh(i,m=md5_hh(m,f,r,i,d[n+1],4,-1530992060),f,r,d[n+4],11,1272893353),m,f,d[n+7],16,-155497632),i,m,d[n+10],23,-1094730640),r=md5_hh(r,i=md5_hh(i,m=md5_hh(m,f,r,i,d[n+13],4,681279174),f,r,d[n+0],11,-358537222),m,f,d[n+3],16,-722521979),i,m,d[n+6],23,76029189),r=md5_hh(r,i=md5_hh(i,m=md5_hh(m,f,r,i,d[n+9],4,-640364487),f,r,d[n+12],11,-421815835),m,f,d[n+15],16,530742520),i,m,d[n+2],23,-995338651),r=md5_ii(r,i=md5_ii(i,m=md5_ii(m,f,r,i,d[n+0],6,-198630844),f,r,d[n+7],10,1126891415),m,f,d[n+14],15,-1416354905),i,m,d[n+5],21,-57434055),r=md5_ii(r,i=md5_ii(i,m=md5_ii(m,f,r,i,d[n+12],6,1700485571),f,r,d[n+3],10,-1894986606),m,f,d[n+10],15,-1051523),i,m,d[n+1],21,-2054922799),r=md5_ii(r,i=md5_ii(i,m=md5_ii(m,f,r,i,d[n+8],6,1873313359),f,r,d[n+15],10,-30611744),m,f,d[n+6],15,-1560198380),i,m,d[n+13],21,1309151649),r=md5_ii(r,i=md5_ii(i,m=md5_ii(m,f,r,i,d[n+4],6,-145523070),f,r,d[n+11],10,-1120210379),m,f,d[n+2],15,718787259),i,m,d[n+9],21,-343485551),m=safe_add(m,h),f=safe_add(f,t),r=safe_add(r,g),i=safe_add(i,e)}return Array(m,f,r,i)}function md5_cmn(d,_,m,f,r,i){return safe_add(bit_rol(safe_add(safe_add(_,d),safe_add(f,i)),r),m)}function md5_ff(d,_,m,f,r,i,n){return md5_cmn(_&m|~_&f,d,_,r,i,n)}function md5_gg(d,_,m,f,r,i,n){return md5_cmn(_&f|m&~f,d,_,r,i,n)}function md5_hh(d,_,m,f,r,i,n){return md5_cmn(_^m^f,d,_,r,i,n)}function md5_ii(d,_,m,f,r,i,n){return md5_cmn(m^(_|~f),d,_,r,i,n)}function safe_add(d,_){var m=(65535&d)+(65535&_);return(d>>16)+(_>>16)+(m>>16)<<16|65535&m}function bit_rol(d,_){return d<<_|d>>>32-_}
const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('file-input');
const result = document.querySelector('.result');
const loading = document.querySelector('.loading');
const error = document.querySelector('.error');
const progressBar = document.querySelector('.progress-bar');
const progressText = document.querySelector('.progress-text');
// Calculate MD5 hash of a file
async function calculateHash(file) {
return new Promise((resolve, reject) => {
const chunkSize = 2097152; // 2MB chunks
const chunks = Math.ceil(file.size / chunkSize);
let currentChunk = 0;
const reader = new FileReader();
let md5Context = '';
reader.onload = function(e) {
const chunk = e.target.result;
md5Context = MD5(md5Context + chunk);
currentChunk++;
// Update progress
const progress = Math.min(100, Math.round((currentChunk / chunks) * 100));
progressBar.style.width = `${progress}%`;
progressText.textContent = `${progress}%`;
if (currentChunk < chunks) {
loadNext();
} else {
resolve(md5Context);
}
};
reader.onerror = function() {
reject(reader.error);
};
function loadNext() {
const start = currentChunk * chunkSize;
const end = Math.min(start + chunkSize, file.size);
reader.readAsBinaryString(file.slice(start, end));
}
loadNext();
});
}
dropZone.addEventListener('click', () => fileInput.click());
dropZone.addEventListener('dragover', (e) => {
e.preventDefault();
dropZone.style.backgroundColor = 'rgba(0, 255, 0, 0.1)';
});
dropZone.addEventListener('dragleave', () => {
dropZone.style.backgroundColor = '';
});
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
dropZone.style.backgroundColor = '';
const file = e.dataTransfer.files[0];
processFile(file);
});
fileInput.addEventListener('change', (e) => {
const file = e.target.files[0];
processFile(file);
});
async function processFile(file) {
if (!file) return;
result.style.display = 'none';
error.style.display = 'none';
loading.style.display = 'block';
progressBar.style.width = '0%';
progressText.textContent = '0%';
try {
const hash = await calculateHash(file);
result.querySelector('.filename').textContent = `FILE: ${file.name}`;
result.querySelector('.hash').textContent = `MD5: ${hash}`;
result.style.display = 'block';
} catch (err) {
error.style.display = 'block';
console.error(err);
} finally {
loading.style.display = 'none';
}
}
</script>
</body>
</html>