Single-page web app to convert between PHP archives (.phar) and ZIP files entirely client‑side. No server, no build step, works from file:// or any static host.
- PHAR → ZIP: Manual PHAR parser (stub + manifest + file data), supports deflate (GZ). Warns on BZip2.
- ZIP → PHAR: Builds PHAR with stub, manifest, raw data (no compression), CRC32, and SHA1 placeholder signature (
GBMBmagic). - Auto detect: One drop zone; dropping
.pharconverts to.zip, dropping.zipconverts to.phar. - Verification: After ZIP → PHAR, the app re-parses the generated PHAR and compares CRC32 of every file.
- Offline after first load: Uses CDN JS (JSZip, FileSaver, pako); once cached by the browser, works offline.
- Open
index.html(double-click is fine; first time needs network for CDNs). - Drag & drop a
.pharor.ziponto the drop zone, or click to choose. - The app detects the type:
.phar→ downloads<name>.zip.zip→ downloads<name>.phar
- For ZIP → PHAR, a verification line shows how many files matched CRC after repack.
- Parsing PHAR: Finds
__HALT_COMPILER(); ?>stub end, reads manifest (length‑prefixed), then file entries; handles deflate based onflags & 0xF000. - Building PHAR: Stub text:
followed by CRLF. Manifest uses API 0x0011, no alias/metadata, no compression. Signature block: type
<?php // PocketMine-MP Plugin __HALT_COMPILER(); ?>
0x00000001, 20 zero bytes, magicGBMB. - Compression: None when creating PHAR; only deflate is decompressed when reading PHAR. BZip2 is not supported in-browser.
- CRC32: Implemented manually (poly 0xEDB88320).
- Vanilla HTML/CSS/JS (no frameworks)
- JSZip 3.10.1 (CDN)
- FileSaver 2.0.5 (CDN)
- pako 2.1.0 (CDN)
index.html- layout + drop zonestyle.css- styling (Apple-like light theme)script.js- parsing/building logic
- BZip2-compressed PHAR entries are not supported.
- Very large files depend on browser memory limits.
- Inspired by the parsing approach from easy-phar/easy-phar.github.io and pharjs/phar.js.