我有一个带有密码的加密存档
" /?*:<|>^&'\"\\ "
fun fx(
srcPath: Path,
password: String = "",
) {
val processBuilder = ProcessBuilder(
libPath,
"t",
srcPath.absolutePathString(),
"-bsp1",
"-p$password",
)
processBuilder.redirectErrorStream(true)
println("pass:$password")
println("passArg:${processBuilder.command().last()}")
val process = processBuilder.start()
println(
process.stdOutput()
)
}
我得到:
pass:" /?*:<|>^&'\"\\ "
passArg:-p" /?*:<|>^&'\"\\ "
7-Zip 22.01 ZS v1.5.5 R2 (x64) : Copyright (c) 1999-2022 Igor Pavlov, 2016-2023 Tino Reichardt : 2023-04-05
Scanning the drive for archives:
1 file, 196620033 bytes (188 MiB)
Testing archive: D:\Games\X\special.7z
ERROR: D:\Games\X\special.7z
Cannot open encrypted archive. Wrong password?
Can't open as archive: 1
Files: 0
Size: 0
Compressed: 0
如果我提供了没有特殊字符的错误通行证
10:04:56.831389500 INFO [ main] : Configuration : Configuration set using the DSL with append=false
pass:a
passArg:-pa
7-Zip 22.01 ZS v1.5.5 R2 (x64) : Copyright (c) 1999-2022 Igor Pavlov, 2016-2023 Tino Reichardt : 2023-04-05
Scanning the drive for archives:
1 file, 196620033 bytes (188 MiB)
Testing archive: D:\Games\X\special.7z
ERROR: D:\Games\X\special.7z
Cannot open encrypted archive. Wrong password?
Can't open as archive: 1
Files: 0
Size: 0
Compressed: 0
我该如何处理?
尝试使用没有特殊字符密码的不同存档,我得到:
pass:a
passArg:-pa
7-Zip 22.01 ZS v1.5.5 R2 (x64) : Copyright (c) 1999-2022 Igor Pavlov, 2016-2023 Tino Reichardt : 2023-04-05
Scanning the drive for archives:
1 file, 174698897 bytes (167 MiB)
Testing archive: D:\Games\X\nospecialenc.7z
--
Path = D:\Games\X\nospecialenc.7z
Type = 7z
Physical Size = 174698897
Headers Size = 1377
Method = LZMA2:23 BCJ 7zAES
Solid = +
Blocks = 2
Everything is Ok
Folders: 36
Files: 47
Size: 605457431
Compressed: 174698897
我可以在 GUI 中使用精确的 pass
" /?*:<|>^&'\"\\ "
(带双引号)提取存档。
我这里该怎么处理?
更新:我已更新以解决评论中提到的问题。
从这个线程来看,这在基于 JVM 的语言甚至 CLI 中似乎都是不可能的。
当我尝试使用该密码创建存档时:
它触发了警告:
不建议在密码中使用字符(对于 PeaZup 和脚本)。如果您需要使用此密码创建或提取存档,您可以忽略该消息,系统将要求您在控制台中以交互方式输入密码。"
我必须选择“
Force typing passwords interactively
”才能设置密码(如前所述,“在控制台中交互式”):
这意味着密码将必须以交互方式输入才能解密。不可能
-pxxx
。