aboutsummaryrefslogtreecommitdiff
path: root/src/zip/archive.rs
diff options
context:
space:
mode:
authorIgor Tolmachev <me@igorek.dev>2024-07-16 17:24:33 +0900
committerIgor Tolmachev <me@igorek.dev>2024-07-16 17:24:33 +0900
commitcc18a545a87ca616f05114d174690e5cc9614669 (patch)
tree51ec845115754bb1d8b41d82e5349db5343a40ec /src/zip/archive.rs
parenta83767f9fbd51df654901b52bdba7838f6a10bf9 (diff)
downloadarchivator-cc18a545a87ca616f05114d174690e5cc9614669.tar.gz
archivator-cc18a545a87ca616f05114d174690e5cc9614669.zip
Optimize encryption
- Add archive for testing encryption of compressed files - Implement incorrect password check - Use custom crc32 function
Diffstat (limited to 'src/zip/archive.rs')
-rw-r--r--src/zip/archive.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/zip/archive.rs b/src/zip/archive.rs
index 79e8ca1..569ad87 100644
--- a/src/zip/archive.rs
+++ b/src/zip/archive.rs
@@ -1,3 +1,4 @@
1use crate::zip::{ZipFileReader, ZipResult};
1use crate::{Archive, Zip}; 2use crate::{Archive, Zip};
2use std::io::{Read, Seek, Write}; 3use std::io::{Read, Seek, Write};
3 4
@@ -5,6 +6,24 @@ impl<Io: Read + Seek> Archive<Zip<Io>> {
5 pub fn comment(&self) -> &String { 6 pub fn comment(&self) -> &String {
6 self.driver.comment() 7 self.driver.comment()
7 } 8 }
9
10 pub fn get_file_reader_by_index_with_password<'d>(
11 &'d mut self,
12 index: usize,
13 password: &[u8],
14 ) -> ZipResult<ZipFileReader<'d, Io>> {
15 self.driver
16 .get_file_reader_with_optional_password(index, Some(password))
17 }
18
19 #[inline]
20 pub fn get_file_reader_by_name_with_password<'d>(
21 &'d mut self,
22 name: &str,
23 password: &[u8],
24 ) -> ZipResult<ZipFileReader<'d, Io>> {
25 self.get_file_reader_by_index_with_password(self.get_file_index(name)?, password)
26 }
8} 27}
9 28
10impl<Io: Read + Write + Seek> Archive<Zip<Io>> {} 29impl<Io: Read + Write + Seek> Archive<Zip<Io>> {}