| Crates.io | zar-cli |
| lib.rs | zar-cli |
| version | 0.1.4 |
| created_at | 2024-12-16 22:06:57.186047+00 |
| updated_at | 2025-02-16 08:24:00.356579+00 |
| description | A command-line utility for reading and writing MacOS signed XAR archives. |
| homepage | https://github.com/igankevich/zar |
| repository | https://github.com/igankevich/zar |
| max_upload_size | |
| id | 1485567 |
| size | 53,016 |
XAR archive reader/writer library that is fuzz-tested agains MacOS xar.
Supports signing and verifying archives.
The easiest way to use zar is via command line interface.
cargo install zar-cli
# archive tmp dir
zar -cf tmp.xar /tmp
# extract the archive
zar -xf tmp.xar /tmp/extracted
# archive tmp dir and sign the archive
openssl genrsa -traditional -out private-key.pem 2048
openssl req -x509 -sha1 -days 1 -noenc -key private-key.pem -out cert.pem -subj /CN=Zar
zar --sign private-key.pem --cert cert.pem -cf tmp.xar /tmp
# verify and extract the archive
zar --trust cert.pem -xf tmp.xar /tmp/extracted
use std::fs::File;
use std::io::Error;
use zar::NoSigner;
fn create_archive() -> Result<(), Error> {
let file = File::create("archive.xar")?;
let mut builder = zar::UnsignedBuilder::new_unsigned(file);
builder.append_dir_all("/tmp", zar::Compression::default(), zar::no_extra_contents)?;
builder.finish()?;
Ok(())
}
fn extract_archive() -> Result<(), Error> {
let file = File::open("archive.xar")?;
let mut archive = zar::Archive::new(file)?;
for i in 0..archive.num_entries() {
let mut entry = archive.entry(i);
println!("{:?}", entry.file());
if let Some(mut reader) = entry.reader()? {
// read the entry...
}
}
Ok(())
}