Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
631 lines (605 loc) · 27.2 KB
/
Copy pathindex.html
File metadata and controls
631 lines (605 loc) · 27.2 KB
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DevBox Zero — 100% Local Privacy Developer Toolkit (JSON, JWT, Base64, Cron, Diff)</title>
<meta name="description" content="Free, instant, 100% browser-local developer toolkit. Format JSON & generate TypeScript interfaces, decode JWTs, parse Cron expressions, encode Base64/URL, compare text diffs, and generate secure UUIDs without sending a single byte to any server." />
<meta name="keywords" content="json formatter, json to typescript, jwt decoder, base64 encoder, cron expression parser, text diff online, uuid generator, local privacy developer tools" />
<meta property="og:title" content="DevBox Zero — Local-First Privacy Developer Toolkit" />
<meta property="og:description" content="Zero tracking, zero server uploads. Instant JSON, JWT, Base64, Cron, Diff & UUID tools right in your browser." />
<meta property="og:type" content="website" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "DevBox Zero",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "Any",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
"description": "100% client-side privacy-first developer toolkit for JSON, JWT, Base64, Cron, Diff, and UUID generation."
}
</script>
<style>
:root {
--bg: #0b0f19;
--panel: #111827;
--panel-2: #1f2937;
--border: #263244;
--text: #e5e7eb;
--muted: #9ca3af;
--accent: #38bdf8;
--accent-2: #818cf8;
--ok: #34d399;
--err: #f87171;
--radius: 12px;
--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
--sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: var(--sans);
background: radial-gradient(circle at top right, rgba(56,189,248,0.08), transparent 40%), var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
flex-direction: column;
}
header {
border-bottom: 1px solid var(--border);
padding: 14px 24px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
background: rgba(11,15,25,0.85);
backdrop-filter: blur(10px);
position: sticky;
top: 0;
z-index: 20;
}
.brand {
display: flex;
align-items: center;
gap: 10px;
font-weight: 700;
font-size: 18px;
letter-spacing: -0.02em;
}
.badge {
font-size: 11px;
padding: 3px 8px;
border-radius: 999px;
background: rgba(52, 211, 153, 0.14);
color: var(--ok);
border: 1px solid rgba(52, 211, 153, 0.3);
font-weight: 600;
}
.header-actions { display: flex; gap: 10px; align-items: center; }
.btn {
background: var(--panel-2);
color: var(--text);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px 14px;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn-primary {
background: linear-gradient(135deg, var(--accent), var(--accent-2));
color: #06101d;
border: none;
}
.btn-primary:hover { opacity: 0.92; color: #06101d; }
.layout {
display: grid;
grid-template-columns: 230px 1fr;
flex: 1;
max-width: 1440px;
width: 100%;
margin: 0 auto;
}
aside {
border-right: 1px solid var(--border);
padding: 18px 12px;
display: flex;
flex-direction: column;
gap: 6px;
}
.nav-btn {
text-align: left;
background: transparent;
border: 1px solid transparent;
color: var(--muted);
padding: 10px 12px;
border-radius: 9px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
display: flex;
align-items: center;
justify-content: space-between;
}
.nav-btn:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.nav-btn.active {
background: rgba(56,189,248,0.12);
border-color: rgba(56,189,248,0.35);
color: #fff;
font-weight: 600;
}
main {
padding: 24px;
display: flex;
flex-direction: column;
gap: 18px;
}
.tool-section { display: none; flex-direction: column; gap: 14px; }
.tool-section.active { display: flex; }
.tool-head h1 { margin: 0 0 4px; font-size: 22px; }
.tool-head p { margin: 0; color: var(--muted); font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
textarea, input[type="text"] {
width: 100%;
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
color: var(--text);
font-family: var(--mono);
font-size: 13px;
padding: 12px 14px;
resize: vertical;
outline: none;
}
textarea:focus, input[type="text"]:focus { border-color: var(--accent); }
textarea { min-height: 300px; line-height: 1.5; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status { font-size: 13px; color: var(--muted); margin-left: auto; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.card {
background: var(--panel);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px;
}
.diff-out {
font-family: var(--mono);
font-size: 13px;
white-space: pre-wrap;
line-height: 1.55;
max-height: 360px;
overflow: auto;
}
.diff-add { background: rgba(52,211,153,0.16); color: #6ee7b7; display: block; padding: 1px 6px; }
.diff-del { background: rgba(248,113,113,0.16); color: #fca5a5; display: block; padding: 1px 6px; }
.diff-eq { color: var(--muted); display: block; padding: 1px 6px; }
.sponsor-box {
margin-top: auto;
background: linear-gradient(180deg, rgba(56,189,248,0.08), rgba(129,140,248,0.06));
border: 1px solid rgba(56,189,248,0.28);
border-radius: var(--radius);
padding: 14px;
font-size: 12.5px;
line-height: 1.5;
}
.sponsor-box strong { color: #fff; display: block; margin-bottom: 6px; }
.addr {
font-family: var(--mono);
font-size: 11px;
background: rgba(0,0,0,0.35);
border: 1px solid var(--border);
border-radius: 6px;
padding: 6px 8px;
word-break: break-all;
margin: 6px 0;
cursor: pointer;
}
.addr:hover { border-color: var(--accent); }
footer {
border-top: 1px solid var(--border);
padding: 14px 24px;
font-size: 12px;
color: var(--muted);
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 10px;
}
dialog#support-modal {
background: var(--panel);
color: var(--text);
border: 1px solid var(--border);
border-radius: 16px;
padding: 22px;
max-width: 680px;
width: calc(100% - 32px);
box-shadow: 0 24px 60px rgba(0,0,0,0.65);
}
dialog#support-modal::backdrop {
background: rgba(5, 8, 15, 0.72);
backdrop-filter: blur(4px);
}
.qr-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
margin: 14px 0;
}
.qr-card {
background: rgba(0,0,0,0.28);
border: 1px solid var(--border);
border-radius: 12px;
padding: 12px;
text-align: center;
}
.qr-card img {
width: 100%;
max-width: 220px;
border-radius: 8px;
display: block;
margin: 8px auto 0;
}
@media (max-width: 860px) {
.layout { grid-template-columns: 1fr; }
aside { border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; }
.grid-2 { grid-template-columns: 1fr; }
.sponsor-box { display: none; }
}
</style>
<link rel="canonical" href="https://devbox-zero-ops.github.io/devbox-zero/" />
</head>
<body>
<div id="xiaheai-shop-banner" class="no-print" style="background:linear-gradient(90deg,#0f172a,#1e3a5f,#0f172a);border-bottom:1px solid rgba(56,189,248,0.35);padding:9px 16px;text-align:center;font-size:13px;color:#e2e8f0;">⚡ <strong>夏禾AI 官方代充</strong>:ChatGPT Plus / Pro 官方通道充值 · 24小时自动发货 · <a href="https://shop.xiaheai.com" target="_blank" rel="noopener" style="color:#38bdf8;font-weight:700;text-decoration:underline;margin-left:4px;">立即前往 shop.xiaheai.com →</a></div>
<header>
<div class="brand">
<span>⚡ DevBox Zero</span>
<span class="badge">100% Local · Zero Server Uploads</span>
</div>
<div class="header-actions">
<a class="btn" href="https://devbox-zero-ops.github.io/chaincalc-zero/" target="_blank" rel="noopener" style="text-decoration:none">🧮 ChainCalc Zero</a>
<button class="btn btn-primary" onclick="openSupport()">💎 Support / Pro Pack (USDT)</button>
</div>
</header>
<div class="layout">
<aside>
<button class="nav-btn active" data-tool="json">JSON & TS Types <span>{}</span></button>
<button class="nav-btn" data-tool="jwt">JWT Decoder <span>🔑</span></button>
<button class="nav-btn" data-tool="base64">Base64 & URL <span>⇄</span></button>
<button class="nav-btn" data-tool="cron">Cron Parser <span>⏱</span></button>
<button class="nav-btn" data-tool="diff">Text Diff <span>±</span></button>
<button class="nav-btn" data-tool="regex">Regex Tester <span>/.*/</span></button>
<button class="nav-btn" data-tool="hash">SHA-256 Hash <span>🔐</span></button>
<button class="nav-btn" data-tool="uuid">UUID & Secrets <span>#</span></button>
<div class="sponsor-box">
<strong>Keep DevBox Zero Ad-Free</strong>
Every tool runs locally in your browser. Tip in USDT (Base / Solana) to support new tools:
<div class="addr" title="Click to copy Base/EVM USDT address" onclick="copyText('0xe4c8739bCC488bD98978CE976511735e0499d432', this)">
Base / EVM: 0xe4c8739bCC488bD98978CE976511735e0499d432
</div>
<div class="addr" title="Click to copy Solana USDT address" onclick="copyText('89XqpaJDKajhYFs4Vmex853yxoEU7HqwnMAPtTDpgZgG', this)">
Solana: 89XqpaJDKajhYFs4Vmex853yxoEU7HqwnMAPtTDpgZgG
</div>
</div>
</aside>
<main>
<!-- JSON Tool -->
<section class="tool-section active" id="tool-json">
<div class="tool-head">
<h1>JSON Formatter, Minifier & TypeScript Generator</h1>
<p>Validate, prettify, minify JSON or convert payloads directly into TypeScript interfaces locally.</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="formatJson(2)">Format (2 spaces)</button>
<button class="btn" onclick="formatJson(0)">Minify</button>
<button class="btn" onclick="jsonToTs()">Generate TS Interface</button>
<button class="btn" onclick="copyEl('json-out')">Copy Output</button>
<span class="status" id="json-status">Ready</span>
</div>
<div class="grid-2">
<textarea id="json-in" placeholder='{"id": 101, "name": "DevBox", "tags": ["local", "fast"], "active": true}'></textarea>
<textarea id="json-out" readonly placeholder="Output appears here..."></textarea>
</div>
</section>
<!-- JWT Tool -->
<section class="tool-section" id="tool-jwt">
<div class="tool-head">
<h1>JWT Token Decoder (Offline)</h1>
<p>Inspect JWT header, payload, and expiration timestamp safely without pasting tokens into third-party servers.</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="decodeJwt()">Decode JWT</button>
<span class="status" id="jwt-status">Paste a JWT below</span>
</div>
<textarea id="jwt-in" style="min-height:110px" placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."></textarea>
<div class="grid-2">
<textarea id="jwt-header" readonly placeholder="Header JSON"></textarea>
<textarea id="jwt-payload" readonly placeholder="Payload JSON"></textarea>
</div>
</section>
<!-- Base64 & URL -->
<section class="tool-section" id="tool-base64">
<div class="tool-head">
<h1>Base64 & URL Encoder / Decoder</h1>
<p>UTF-8 safe Base64 and URI component encoding/decoding.</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="b64Encode()">Base64 Encode</button>
<button class="btn" onclick="b64Decode()">Base64 Decode</button>
<button class="btn" onclick="urlEnc()">URL Encode</button>
<button class="btn" onclick="urlDec()">URL Decode</button>
<button class="btn" onclick="copyEl('b64-out')">Copy Output</button>
<span class="status" id="b64-status">Ready</span>
</div>
<div class="grid-2">
<textarea id="b64-in" placeholder="Input text..."></textarea>
<textarea id="b64-out" readonly placeholder="Result..."></textarea>
</div>
</section>
<!-- Cron Parser -->
<section class="tool-section" id="tool-cron">
<div class="tool-head">
<h1>5-Field Cron Expression Explainer</h1>
<p>Verify standard cron schedules (minute hour day-of-month month day-of-week).</p>
</div>
<div class="toolbar">
<input type="text" id="cron-in" value="0 */6 * * *" style="max-width:300px" />
<button class="btn btn-primary" onclick="explainCron()">Explain</button>
</div>
<div class="card" id="cron-out" style="font-family:var(--mono);font-size:14px;line-height:1.7"></div>
</section>
<!-- Text Diff -->
<section class="tool-section" id="tool-diff">
<div class="tool-head">
<h1>Line-by-Line Text Diff</h1>
<p>Compare two configs, JSON files, or code snippets locally.</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="runDiff()">Compare</button>
</div>
<div class="grid-2">
<textarea id="diff-a" style="min-height:200px" placeholder="Original text..."></textarea>
<textarea id="diff-b" style="min-height:200px" placeholder="Modified text..."></textarea>
</div>
<div class="card diff-out" id="diff-out">Click Compare to see line differences.</div>
</section>
<!-- Regex Tester -->
<section class="tool-section" id="tool-regex">
<div class="tool-head">
<h1>Regex Live Tester & Match Extractor</h1>
<p>Test JavaScript regular expressions with flags and inspect every matched group locally.</p>
</div>
<div class="toolbar">
<input type="text" id="rx-pat" value="([a-z0-9._%+-]+)@([a-z0-9.-]+\.[a-z]{2,})" style="flex:1;min-width:220px" placeholder="Pattern..." oninput="runRegex()" />
<input type="text" id="rx-flags" value="gi" style="width:70px" placeholder="flags" oninput="runRegex()" />
<span class="status" id="rx-status">Ready</span>
</div>
<div class="grid-2">
<textarea id="rx-text" oninput="runRegex()" placeholder="Test text...">Contact [email protected] or [email protected] for details.</textarea>
<textarea id="rx-out" readonly placeholder="Matches..."></textarea>
</div>
</section>
<!-- SHA-256 / SHA-512 Hash -->
<section class="tool-section" id="tool-hash">
<div class="tool-head">
<h1>SHA-256 & SHA-512 Cryptographic Hasher</h1>
<p>Compute Web Crypto API digests locally without transmitting sensitive text.</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="runHash()">Compute Digests</button>
<button class="btn" onclick="copyEl('hash-out')">Copy Output</button>
</div>
<div class="grid-2">
<textarea id="hash-in" placeholder="Enter text to hash..." oninput="runHash()">hello devbox zero</textarea>
<textarea id="hash-out" readonly placeholder="SHA-256 / SHA-512 output..."></textarea>
</div>
</section>
<!-- UUID & Secrets -->
<section class="tool-section" id="tool-uuid">
<div class="tool-head">
<h1>Cryptographic UUID v4 & Random Secret Generator</h1>
<p>Uses Web Crypto API (`crypto.getRandomValues` / `crypto.randomUUID`).</p>
</div>
<div class="toolbar">
<button class="btn btn-primary" onclick="genUuids()">Generate 10 UUID v4</button>
<button class="btn" onclick="genSecrets()">Generate 256-bit Hex Keys</button>
<button class="btn" onclick="copyEl('uuid-out')">Copy All</button>
</div>
<textarea id="uuid-out" readonly></textarea>
</section>
</main>
</div>
<footer>
<span>DevBox Zero · 100% Client-Side Open Developer Utilities</span>
<span>Privacy Guarantee: Zero telemetry, zero cookies, zero network requests.</span>
</footer>
<dialog id="support-modal">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:10px">
<strong style="font-size:18px">💎 Support DevBox Zero / 赞赏支持</strong>
<button class="btn" onclick="document.getElementById('support-modal').close()">Close</button>
</div>
<p style="margin:0 0 12px;color:var(--muted);font-size:13.5px">
DevBox Zero is 100% free, ad-free, and runs locally in your browser. Support ongoing tools via WeChat Pay, Alipay, or zero-fee USDT:
</p>
<div class="qr-grid">
<div class="qr-card">
<strong>WeChat Pay / 微信赞赏</strong>
<img src="./assets/wechat-pay.jpg" alt="WeChat Pay QR Code" loading="lazy" />
</div>
<div class="qr-card">
<strong>Alipay / 支付宝赞赏</strong>
<img src="./assets/alipay.jpg" alt="Alipay QR Code" loading="lazy" />
</div>
</div>
<div style="font-size:12.5px;color:var(--muted);margin-top:8px">Crypto USDT (Click to copy):</div>
<div class="addr" onclick="copyText('0xe4c8739bCC488bD98978CE976511735e0499d432', this)">
Base / EVM USDT: 0xe4c8739bCC488bD98978CE976511735e0499d432
</div>
<div class="addr" onclick="copyText('89XqpaJDKajhYFs4Vmex853yxoEU7HqwnMAPtTDpgZgG', this)">
Solana USDT / SOL: 89XqpaJDKajhYFs4Vmex853yxoEU7HqwnMAPtTDpgZgG
</div>
</dialog>
<script>
document.querySelectorAll('.nav-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.nav-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.tool-section').forEach(s => s.classList.remove('active'));
btn.classList.add('active');
document.getElementById('tool-' + btn.dataset.tool).classList.add('active');
});
});
function setStatus(id, msg, cls) {
const el = document.getElementById(id);
el.textContent = msg;
el.className = 'status ' + (cls || '');
}
function copyEl(id) {
const val = document.getElementById(id).value;
if (val) navigator.clipboard.writeText(val);
}
function copyText(text, el) {
navigator.clipboard.writeText(text);
const orig = el.textContent;
el.textContent = 'Copied: ' + text;
setTimeout(() => { el.textContent = orig; }, 1400);
}
function openSupport() {
document.getElementById('support-modal').showModal();
}
function formatJson(spaces) {
try {
const parsed = JSON.parse(document.getElementById('json-in').value);
document.getElementById('json-out').value = JSON.stringify(parsed, null, spaces);
setStatus('json-status', 'Valid JSON', 'ok');
} catch (e) {
setStatus('json-status', 'Error: ' + e.message, 'err');
}
}
function jsonToTs() {
try {
const parsed = JSON.parse(document.getElementById('json-in').value);
function infer(v, indent = ' ') {
if (v === null) return 'null';
if (Array.isArray(v)) return (v.length ? infer(v[0], indent) : 'unknown') + '[]';
if (typeof v === 'object') {
const lines = Object.entries(v).map(([k, val]) => `${indent}${/^[a-zA-Z_$][\w$]*$/.test(k) ? k : JSON.stringify(k)}: ${infer(val, indent + ' ')};`);
return `{\n${lines.join('\n')}\n${indent.slice(2)}}`;
}
return typeof v;
}
document.getElementById('json-out').value = `export interface RootObject ${infer(parsed)}`;
setStatus('json-status', 'TypeScript interface generated', 'ok');
} catch (e) {
setStatus('json-status', 'Error: ' + e.message, 'err');
}
}
function decodeJwt() {
try {
const parts = document.getElementById('jwt-in').value.trim().split('.');
if (parts.length < 2) throw new Error('Invalid JWT format');
const dec = s => JSON.parse(decodeURIComponent(escape(atob(s.replace(/-/g, '+').replace(/_/g, '/')))));
const header = dec(parts[0]);
const payload = dec(parts[1]);
document.getElementById('jwt-header').value = JSON.stringify(header, null, 2);
document.getElementById('jwt-payload').value = JSON.stringify(payload, null, 2);
const exp = payload.exp ? new Date(payload.exp * 1000).toISOString() : 'No exp claim';
setStatus('jwt-status', 'Decoded · Exp: ' + exp, 'ok');
} catch (e) {
setStatus('jwt-status', 'Error: ' + e.message, 'err');
}
}
function b64Encode() {
try {
const v = document.getElementById('b64-in').value;
document.getElementById('b64-out').value = btoa(unescape(encodeURIComponent(v)));
setStatus('b64-status', 'Encoded to Base64', 'ok');
} catch (e) { setStatus('b64-status', e.message, 'err'); }
}
function b64Decode() {
try {
const v = document.getElementById('b64-in').value.trim();
document.getElementById('b64-out').value = decodeURIComponent(escape(atob(v)));
setStatus('b64-status', 'Decoded from Base64', 'ok');
} catch (e) { setStatus('b64-status', e.message, 'err'); }
}
function urlEnc() {
document.getElementById('b64-out').value = encodeURIComponent(document.getElementById('b64-in').value);
setStatus('b64-status', 'URL Encoded', 'ok');
}
function urlDec() {
try {
document.getElementById('b64-out').value = decodeURIComponent(document.getElementById('b64-in').value);
setStatus('b64-status', 'URL Decoded', 'ok');
} catch (e) { setStatus('b64-status', e.message, 'err'); }
}
function explainCron() {
const parts = document.getElementById('cron-in').value.trim().split(/\s+/);
const out = document.getElementById('cron-out');
if (parts.length !== 5) {
out.textContent = 'Invalid cron: expected 5 fields (minute hour day-of-month month day-of-week).';
return;
}
const names = ['Minute (0-59)', 'Hour (0-23)', 'Day of Month (1-31)', 'Month (1-12)', 'Day of Week (0-6)'];
out.innerHTML = parts.map((p, i) => `<div><strong>${names[i]}:</strong> ${p === '*' ? 'Every' : p}</div>`).join('');
}
explainCron();
function runDiff() {
const a = document.getElementById('diff-a').value.split('\n');
const b = document.getElementById('diff-b').value.split('\n');
const max = Math.max(a.length, b.length);
const out = [];
for (let i = 0; i < max; i++) {
if (a[i] === b[i]) {
out.push(`<span class="diff-eq"> ${(a[i] ?? '').replace(/</g, '<')}</span>`);
} else {
if (a[i] !== undefined) out.push(`<span class="diff-del">- ${a[i].replace(/</g, '<')}</span>`);
if (b[i] !== undefined) out.push(`<span class="diff-add">+ ${b[i].replace(/</g, '<')}</span>`);
}
}
document.getElementById('diff-out').innerHTML = out.join('');
}
function genUuids() {
const list = Array.from({ length: 10 }, () => crypto.randomUUID());
document.getElementById('uuid-out').value = list.join('\n');
}
function genSecrets() {
const list = Array.from({ length: 5 }, () => {
const arr = new Uint8Array(32);
crypto.getRandomValues(arr);
return Array.from(arr, b => b.toString(16).padStart(2, '0')).join('');
});
document.getElementById('uuid-out').value = list.join('\n');
}
function runRegex() {
try {
const pat = document.getElementById('rx-pat').value;
const flags = document.getElementById('rx-flags').value;
const text = document.getElementById('rx-text').value;
const re = new RegExp(pat, flags.includes('g') ? flags : flags + 'g');
const matches = [...text.matchAll(re)];
document.getElementById('rx-out').value = matches.length
? matches.map((m, i) => `#${i + 1} [idx ${m.index}]: ${m[0]}${m.length > 1 ? ' | groups: ' + JSON.stringify(m.slice(1)) : ''}`).join('\n')
: 'No matches.';
setStatus('rx-status', `${matches.length} match(es)`, 'ok');
} catch (e) {
setStatus('rx-status', 'Error: ' + e.message, 'err');
}
}
async function runHash() {
const txt = document.getElementById('hash-in').value;
const enc = new TextEncoder().encode(txt);
const toHex = buf => Array.from(new Uint8Array(buf), b => b.toString(16).padStart(2, '0')).join('');
const [h256, h512] = await Promise.all([
crypto.subtle.digest('SHA-256', enc),
crypto.subtle.digest('SHA-512', enc)
]);
document.getElementById('hash-out').value = `SHA-256:\n${toHex(h256)}\n\nSHA-512:\n${toHex(h512)}`;
}
genUuids(); runRegex(); runHash();
</script>
<div id="xiaheai-suite-bar" class="no-print" style="text-align:center;font-size:12.5px;color:#94a3b8;padding:14px 12px;border-top:1px solid rgba(148,163,184,0.2);margin-top:24px;line-height:1.8;">XiaheAI Zero-Tracking Suite: <a href="https://devbox-zero-ops.github.io/xiaheai-hub/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">Hub</a> · <a href="https://devbox-zero-ops.github.io/tokencost-zero/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">TokenCost Zero</a> · <a href="https://devbox-zero-ops.github.io/devbox-zero/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">DevBox Zero</a> · <a href="https://devbox-zero-ops.github.io/invoice-zero/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">InvoiceZero</a> · <a href="https://devbox-zero-ops.github.io/resumemd-zero/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">ResumeMD Zero</a> · <a href="https://devbox-zero-ops.github.io/chaincalc-zero/" target="_blank" rel="noopener" style="color:#38bdf8;margin:0 6px;">ChainCalc Zero</a><br/><a href="https://devbox-zero-ops.github.io/xiaheai-hub/cursor-vs-claude-vs-chatgpt.html" target="_blank" rel="noopener" style="color:#7dd3fc;margin:0 6px;">Plus / Claude / Cursor Calculator</a> · <a href="https://devbox-zero-ops.github.io/xiaheai-hub/pro.html" target="_blank" rel="noopener" style="color:#4ade80;font-weight:700;margin:0 6px;">Source Code Bundle (¥29 / 5 USDT)</a> · <a href="https://shop.xiaheai.com" target="_blank" rel="noopener" style="color:#38bdf8;font-weight:700;margin:0 6px;">XiaheAI Official Store (shop.xiaheai.com)</a></div>
</body>
</html>