Skip to content

Instantly share code, notes, and snippets.

@Gjum
Created July 8, 2017 17:17
Show Gist options
  • Save Gjum/f7e95799183b5710a6c9341463e167a0 to your computer and use it in GitHub Desktop.
Save Gjum/f7e95799183b5710a6c9341463e167a0 to your computer and use it in GitHub Desktop.
zip-rs deflate error
from zipfile import ZipFile
def main():
with ZipFile('test.zip').open('data') as f:
data = f.read()
for i, b in enumerate(data):
print(('%02x ' % b).upper(), end='')
if (i+1) % 17 == 0:
print()
if __name__ == '__main__':
main()
extern crate zip;
use std::fmt::Write;
use std::fs::File;
use std::io;
use std::io::Read;
fn do_work()
-> Result<(), io::Error> {
let zip_file = try!(File::open("test.zip"));
let mut zip_archive = try!(zip::ZipArchive::new(zip_file));
let mut file = try!(zip_archive.by_index(0));
let contents = &mut [0; 256*256*17];
try!(file.read(contents));
let mut s = String::new();
for (i, &byte) in contents.iter().enumerate() {
write!(&mut s, "{:02X} ", byte).expect("Unable to write");
if (i+1) % 17 == 0 {
write!(&mut s, "\n").expect("Unable to write");
}
}
println!("{}", s);
Ok(())
}
fn main() {
do_work().expect("error reading test.zip");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment