utilityjavascript1910
HTML Encrypt & Decrypt Tool (Obfuscator & Multi-Round Decryptor)
Tools enkripsi HTML ke JavaScript loader (Normal, Full, UTF-8) dan dekripsi otomatis multi-round unescape & decodeURIComponent dari html-code-generator.com.
Vamz Spectre14 Nov 2026263 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/html-encrypt-decrypt" -o html-encrypt-decrypt.js
# 2. Jalankan script
node html-encrypt-decrypt.js
Panduan Penggunaan:
// Download snippet langsung: curl -sL "https://code.vamxapi.my.id/snippet/raw/html-encrypt-decrypt" -o html-encrypt-decrypt.js // Contoh Penggunaan: node html-encrypt-decrypt.js test node html-encrypt-decrypt.js encrypt "<h1>Hello World</h1>" utf8 node html-encrypt-decrypt.js decrypt "<script>document.write(...)</script>"
html-encrypt-decrypt.js(263 lines)
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
/**
* HTML Encrypt & Decrypt Scraper / Tool
* Reverse-Engineered from: https://www.html-code-generator.com/tools/html-encrypt-decrypt
* Author: Vamz Spectre / VamxAPI
*
* Download:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/html-encrypt-decrypt" -o html-encrypt-decrypt.js
*
* Capabilities:
* - Encrypt HTML into JavaScript loader (Normal, Full, UTF-8)
* - Decrypt obfuscated HTML back to raw source (recursive multi-round unescape & decodeURIComponent)
*
* Usage:
* node html-encrypt-decrypt.js encrypt "<h1>Hello World</h1>" utf8
* node html-encrypt-decrypt.js decrypt "<script>document.write(...)</script>"
* node html-encrypt-decrypt.js test
*/
function escapeString(str) {
if (typeof escape === 'function') {
return escape(str);
}
return encodeURI(str)
.replace(/%20/g, ' ')
.replace(/#/g, '%23')
.replace(/&/g, '%26')
.replace(/\+/g, '%2B');
}
function unescapeString(str) {
if (typeof unescape === 'function') {
return unescape(str);
}
return decodeURI(str);
}
class HtmlEncryptDecrypt {
/**
* Encrypt HTML code into JavaScript loader
* @param {string} html Raw HTML string
* @param {string|number} mode 'normal' (0), 'full' (1), 'utf8' (2)
*/
static encrypt(html, mode = 'utf8') {
if (!html || typeof html !== 'string') {
throw new Error('HTML code is required for encryption');
}
const trimmed = html.trim();
let encoded = '';
let method = '';
let modeKey = 'utf8';
const normalizedMode = String(mode).toLowerCase();
if (normalizedMode === 'normal' || normalizedMode === '0') {
modeKey = 'normal';
encoded = escapeString(trimmed);
method = 'unescape';
} else if (normalizedMode === 'full' || normalizedMode === '1') {
modeKey = 'full';
let d = '';
const len = trimmed.length;
for (let i = 0; i < len; i++) {
const code = trimmed.charCodeAt(i);
if (code > 255) {
d += '%u' + code.toString(16).toUpperCase().padStart(4, '0');
} else {
const ea = code % 16;
d += '%' + '0123456789ABCDEF'.substr(Math.floor(code / 16), 1) + '0123456789ABCDEF'.substr(ea, 1);
}
}
encoded = d;
method = 'unescape';
} else {
modeKey = 'utf8';
encoded = encodeURIComponent(trimmed).replace(/'/g, "\\'");
method = 'decodeURIComponent';
}
const script = [
'<script>',
'<!-- code by https://www.html-code-generator.com -->',
`document.write(${method}('${encoded}'));`,
'</script>'
].join('\n');
return {
status: true,
action: 'encrypt',
mode: modeKey,
method: method,
original_length: trimmed.length,
encrypted_length: script.length,
result: script
};
}
/**
* Decrypt encrypted JavaScript / obfuscated HTML code
* @param {string} code Encrypted code or script
* @param {number} maxRounds Maximum rounds for nested decoding (default: 10)
*/
static decrypt(code, maxRounds = 10) {
if (!code || typeof code !== 'string') {
throw new Error('Encrypted code is required for decryption');
}
let input = code.trim();
const isDecodeUri = /decodeURIComponent\s*\(/i.test(input);
const isUnescape = /unescape\s*\(/i.test(input);
if (isUnescape || (!isDecodeUri && /%[0-9A-Fa-f]{2}/.test(input))) {
let current = input;
let rounds = 0;
for (; rounds < maxRounds;) {
const prev = current;
if (/document\.write\s*\(\s*unescape\s*\(/i.test(current)) {
const cleaned = current
.replace(/<script[^>]*>/gi, '')
.replace(/<\/script>/gi, '')
.replace(/<!--.*?-->/gs, '')
.replace(/.*document\.write\s*\(\s*unescape\(['"]/i, '')
.replace(/['"]\s*\)\s*\)\s*;?\s*$/i, '')
.trim();
current = unescapeString(cleaned);
} else if (/%[0-9A-Fa-f]{2}|%u[0-9A-Fa-f]{4}/i.test(current)) {
current = unescapeString(current);
} else {
break;
}
rounds++;
if (current === prev) break;
}
return {
status: true,
action: 'decrypt',
detected_type: 'unescape',
rounds: rounds,
result: current
};
} else {
let cleaned = input
.replace(/<script[^>]*>/gi, '')
.replace(/<\/script>/gi, '')
.replace(/<!--.*?-->/gs, '')
.replace(/.*document\.write\s*\(\s*decodeURIComponent\(['"]/i, '')
.replace(/['"]\s*\)\s*\)\s*;?\s*$/i, '')
.trim();
const match = cleaned.match(/document\.write\s*\(\s*(?:decodeURIComponent|unescape)\s*\(\s*(['"])((?:\\.|(?!\1).)*)\1\s*\)\s*\)/i);
let payload = match ? match[2] : cleaned;
payload = payload.replace(/\\'/g, "'");
let prev = null;
let rounds = 0;
for (let i = 0; i < maxRounds && payload !== prev; i++) {
prev = payload;
try {
payload = decodeURIComponent(prev);
rounds++;
} catch {
break;
}
}
return {
status: true,
action: 'decrypt',
detected_type: 'decodeURIComponent',
rounds: rounds,
result: payload
};
}
}
/**
* Run verification suite across all modes
* @param {string} sampleHtml Sample HTML to test
*/
static runSelfTest(sampleHtml = '<div class="banner"><h1>Hello World!</h1><p>VamxAPI Official</p></div>') {
const modes = ['normal', 'full', 'utf8'];
const results = {};
for (const m of modes) {
const encrypted = HtmlEncryptDecrypt.encrypt(sampleHtml, m);
const decrypted = HtmlEncryptDecrypt.decrypt(encrypted.result);
results[m] = {
encrypted_preview: encrypted.result.slice(0, 80) + '...',
decrypted_matches: decrypted.result === sampleHtml.trim(),
rounds: decrypted.rounds,
detected_type: decrypted.detected_type
};
}
return {
status: true,
test_suite: 'HtmlEncryptDecrypt Self-Test',
sample_input: sampleHtml,
all_passed: Object.values(results).every(r => r.decrypted_matches),
details: results
};
}
}
// ==================== CLI RUNNER ====================
if (require.main === module) {
(async () => {
try {
const firstArg = process.argv[2];
const secondArg = process.argv[3];
const thirdArg = process.argv[4];
if (!firstArg || firstArg === 'help' || firstArg === '--help') {
console.log(JSON.stringify({
status: false,
message: 'Usage: node html-encrypt-decrypt.js <command|input> [mode/options]',
commands: {
encrypt: 'node html-encrypt-decrypt.js encrypt "<h1>Hello</h1>" [normal|full|utf8]',
decrypt: 'node html-encrypt-decrypt.js decrypt "<script>document.write(...)</script>"',
test: 'node html-encrypt-decrypt.js test',
auto: 'node html-encrypt-decrypt.js "<h1>Hello</h1>"'
}
}, null, 2));
return;
}
let response;
if (firstArg === 'test') {
response = HtmlEncryptDecrypt.runSelfTest(secondArg);
} else if (firstArg === 'encrypt') {
if (!secondArg) {
throw new Error('Please provide HTML content to encrypt: node html-encrypt-decrypt.js encrypt "<html_code>" [mode]');
}
response = HtmlEncryptDecrypt.encrypt(secondArg, thirdArg || 'utf8');
} else if (firstArg === 'decrypt') {
if (!secondArg) {
throw new Error('Please provide code to decrypt: node html-encrypt-decrypt.js decrypt "<encrypted_code>"');
}
response = HtmlEncryptDecrypt.decrypt(secondArg);
} else {
// Auto-detect mode
const isEncrypted = /document\.write\s*\(|<script[^>]*>|%[0-9A-Fa-f]{2}/i.test(firstArg);
if (isEncrypted) {
response = HtmlEncryptDecrypt.decrypt(firstArg);
} else {
response = HtmlEncryptDecrypt.encrypt(firstArg, secondArg || 'utf8');
}
}
console.log(JSON.stringify(response, null, 2));
} catch (err) {
console.error(JSON.stringify({
status: false,
error: err.message
}, null, 2));
process.exit(1);
}
})();
}
module.exports = HtmlEncryptDecrypt;