replace-in-zipfile
Put a placeholder file into a zipfile and replace it later. Supports streaming!
You can use any filename for your placeholder file. The matching is performed using the filesize and the file's CRC32. (Yes, there's a chance of checksum collision here!)
A tool called make-magic
is provided to create high entropy placeholder data.
Command line usage
# create a placeholder whith high entropymake-magic 512 > data/magic# and put it into a zipfile along with other filesecho "Stuff" > data/stuffzip -r data data# you can now replace the magic data with any other contentecho "HEY!" | replace-in-zipfile data.zip data/magic > unpack/new.zip# Let's unpack the new zipfile to see if it worked!cd unpackunzip new.zipcd datacat magic # displays "Hey!"
Javascript usage
const fs =const concat =const replaceFileInzip =if processargvlength<4consoleconsoleprocessconst zipFileName = processargv2const magicFileName = processargv3const magicData = fsprocessstdin