From c689510345a9ed0fd72f34804d06bd105d32a7ce Mon Sep 17 00:00:00 2001 From: Mohamed Ashref <102254424+MohamedAshref371@users.noreply.github.com> Date: Wed, 26 Aug 2026 16:13:02 +0300 Subject: [PATCH 1/4] Add password support --- src/readsevenzip/HttpIsoReader.java | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/readsevenzip/HttpIsoReader.java b/src/readsevenzip/HttpIsoReader.java index 0ab20fc..88e8110 100644 --- a/src/readsevenzip/HttpIsoReader.java +++ b/src/readsevenzip/HttpIsoReader.java @@ -82,12 +82,12 @@ private static void usage() { } public Boolean open(String URL) { - return open(URL, null); + return open(URL, null, null); } - public Boolean open(String URL, ArchiveFormat type) { + public Boolean open(String URL, ArchiveFormat type, String password) { try { - archive = SevenZip.openInArchive(type, new MonitorIInStream(new HttpIInStream(URL))); + archive = SevenZip.openInArchive(type, new MonitorIInStream(new HttpIInStream(URL)), password); return true; } catch (Exception ex) { return false; @@ -95,22 +95,24 @@ public Boolean open(String URL, ArchiveFormat type) { } public Boolean open(File file) { - return open(file, null); + return open(file, null, null); } - public Boolean open(File file, ArchiveFormat type) { + public Boolean open(File file, ArchiveFormat type, String password) { try { archive = SevenZip.openInArchive(type, new MonitorIInStream( new RandomAccessFileInStream( - new RandomAccessFile(file, "r")))); + new RandomAccessFile(file, "r"))), + password + ); return true; } catch (Exception ex) { return false; } } - public void getFile(String sourceFilePath, String targetFilePath) throws IOException, SevenZipException { + public void getFile(String sourceFilePath, String targetFilePath, String password) throws IOException, SevenZipException { File f = new File(targetFilePath); final FileOutputStream fos = new FileOutputStream(f); @@ -146,7 +148,7 @@ public int write(byte[] data) throws SevenZipException { throw new SevenZipException(ex); } } - }); + }, password); if (result == ExtractOperationResult.OK) { fos.flush(); fos.close(); @@ -204,6 +206,7 @@ public static void main(String[] a) throws Exception { ArchiveFormat archive_type = null; String extract_filename = null; String output_filename = null; + String password = null; boolean list_archive_content = false; for (String arg : a) { @@ -232,6 +235,8 @@ public static void main(String[] a) throws Exception { list_archive_content = true; } else if (arg_lower.startsWith("/o=") || arg_lower.startsWith("-o=")) { output_filename = arg.substring(3); + } else if (arg_lower.startsWith("/p=") || arg_lower.startsWith("-p=")) { + password = arg.substring(3); } else if (arg_lower.startsWith("/v") || arg_lower.startsWith("-v") || arg_lower.startsWith("--v")) { version(); System.exit(0); @@ -255,14 +260,14 @@ public static void main(String[] a) throws Exception { Boolean result = false; if (archive_filename.toLowerCase().startsWith("http://")) { System.out.println("Opening HTTP archive '" + archive_filename + "'."); - result = reader.open(archive_filename, archive_type); + result = reader.open(archive_filename, archive_type, password); } else if (archive_filename.toLowerCase().startsWith("https://")) { System.out.println("Opening HTTPS archive '" + archive_filename + "'."); - result = reader.open(archive_filename, archive_type); + result = reader.open(archive_filename, archive_type, password); } else { System.out.println("Opening FILE archive '" + archive_filename + "'."); try { - result = reader.open(new File(archive_filename), archive_type); + result = reader.open(new File(archive_filename), archive_type, password); } catch(Exception e){ System.out.println("Invalid '" + archive_type + "' file '" + archive_filename + "'."); @@ -301,7 +306,7 @@ public static void main(String[] a) throws Exception { System.out.println("Extracting file '" + extract_filename + "' ..."); try { - reader.getFile(extract_filename, output_filename); + reader.getFile(extract_filename, output_filename, password); reader.close(); } catch(Exception e){ From 4a98d173d92ab2d83beea27c42fec5eb4b34cf0a Mon Sep 17 00:00:00 2001 From: Mohamed Ashref <102254424+MohamedAshref371@users.noreply.github.com> Date: Wed, 26 Aug 2026 17:20:10 +0300 Subject: [PATCH 2/4] Add password option to help output --- src/readsevenzip/HttpIsoReader.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/readsevenzip/HttpIsoReader.java b/src/readsevenzip/HttpIsoReader.java index 88e8110..e053df1 100644 --- a/src/readsevenzip/HttpIsoReader.java +++ b/src/readsevenzip/HttpIsoReader.java @@ -63,6 +63,7 @@ private static void usage() { System.out.println(" /e -e filename to extract out of the archive"); System.out.println(" /l -l list content of archive"); System.out.println(" /o -o output filename for the extracted file"); + System.out.println(" /p -p set password"); System.out.println(" /v -v show version info\n"); System.out.println("Example:"); System.out.println(" java -jar re7zip.jar /t=iso\n" From 2b6f6182532fe3eeb3f867b4a4f683e527ded23b Mon Sep 17 00:00:00 2001 From: Mohamed Ashref Date: Fri, 28 Aug 2026 10:52:23 +0300 Subject: [PATCH 3/4] Simple modification --- README.md | 1 + src/readsevenzip/HttpIsoReader.java | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8921a03..0f473cc 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Options: hfs, gzip, cpio, bzip2, 7z, z, arj, cab, lzh, chm, nsis, ar, rpm, udf, wim, xar, fat, ntfs /a -a archive filename or URL location of archive + /p -p password for the archive /e -e filename to extract out of the archive /l -l list content of archive /o -o output filename for the extracted file diff --git a/src/readsevenzip/HttpIsoReader.java b/src/readsevenzip/HttpIsoReader.java index e053df1..85a17e2 100644 --- a/src/readsevenzip/HttpIsoReader.java +++ b/src/readsevenzip/HttpIsoReader.java @@ -60,10 +60,10 @@ private static void usage() { } System.out.println(" /a -a archive filename or URL location of archive"); + System.out.println(" /p -p password for the archive"); System.out.println(" /e -e filename to extract out of the archive"); System.out.println(" /l -l list content of archive"); System.out.println(" /o -o output filename for the extracted file"); - System.out.println(" /p -p set password"); System.out.println(" /v -v show version info\n"); System.out.println("Example:"); System.out.println(" java -jar re7zip.jar /t=iso\n" @@ -105,8 +105,7 @@ public Boolean open(File file, ArchiveFormat type, String password) { new MonitorIInStream( new RandomAccessFileInStream( new RandomAccessFile(file, "r"))), - password - ); + password); return true; } catch (Exception ex) { return false; @@ -205,9 +204,9 @@ public static void main(String[] a) throws Exception { String archive_filename = null; String archive_type_arg; ArchiveFormat archive_type = null; + String password = null; String extract_filename = null; String output_filename = null; - String password = null; boolean list_archive_content = false; for (String arg : a) { @@ -230,14 +229,14 @@ public static void main(String[] a) throws Exception { } } else if (arg_lower.startsWith("/a=") || arg_lower.startsWith("-a=")) { archive_filename = arg.substring(3); + } else if (arg_lower.startsWith("/p=") || arg_lower.startsWith("-p=")) { + password = arg.substring(3); } else if (arg_lower.startsWith("/e=") || arg_lower.startsWith("-e=")) { extract_filename = arg.substring(3); } else if (arg_lower.equals("/l") || arg_lower.equals("-l")) { list_archive_content = true; } else if (arg_lower.startsWith("/o=") || arg_lower.startsWith("-o=")) { output_filename = arg.substring(3); - } else if (arg_lower.startsWith("/p=") || arg_lower.startsWith("-p=")) { - password = arg.substring(3); } else if (arg_lower.startsWith("/v") || arg_lower.startsWith("-v") || arg_lower.startsWith("--v")) { version(); System.exit(0); From 02aa9fac96345eb74eb9644c2630d4ac479edbf3 Mon Sep 17 00:00:00 2001 From: Mohamed Ashref <102254424+MohamedAshref371@users.noreply.github.com> Date: Sat, 29 Aug 2026 10:02:17 +0300 Subject: [PATCH 4/4] refactor: separate extractSlow calls for password --- src/readsevenzip/HttpIsoReader.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/readsevenzip/HttpIsoReader.java b/src/readsevenzip/HttpIsoReader.java index 85a17e2..886f598 100644 --- a/src/readsevenzip/HttpIsoReader.java +++ b/src/readsevenzip/HttpIsoReader.java @@ -129,7 +129,7 @@ public void getFile(String sourceFilePath, String targetFilePath, String passwor final long[] sizeArray = new long[1]; final Long size = item.getSize(); - result = item.extractSlow(new ISequentialOutStream() { + ISequentialOutStream outStream = new ISequentialOutStream() { long loaded = 0; @@ -148,7 +148,13 @@ public int write(byte[] data) throws SevenZipException { throw new SevenZipException(ex); } } - }, password); + }; + + if (password == null) + result = item.extractSlow(outStream); + else + result = item.extractSlow(outStream, password); + if (result == ExtractOperationResult.OK) { fos.flush(); fos.close();