【发布时间】:2014-06-20 13:18:26
【问题描述】:
我使用 DotNetZip 1.9.3 库,但在 1 个存档中使用 BZip2 和 AES256 时遇到了问题。 ZipOutputStream 工作正常,但 ZipInputStream 得到错误的 BZip2 标头。如果我使用通用放气算法,一切都很好。
我创建 ZipOutputStream(从文件流):
protected override Stream OnCreateStream(string path)
{
var encryptedStream = new ZipOutputStream(base.OnCreateStream(path))
{
Password = this.Password,
Encryption = EncryptionAlgorithm.WinZipAes256,
// CompressionMethod = CompressionMethod.BZip2,
};
var entry = encryptedStream.PutNextEntry("_");
return encryptedStream;
}
而且我总是在工作完成后处理 ZipOutputStream。
流以读取 zip 存档:
protected override Stream OnCreateStream(string path)
{
ZipInputStream stream = new ZipInputStream(base.OnCreateStream(path))
{
Password = this.Password
};
var entry = stream.GetNextEntry();
return stream;
}
如果我取消注释压缩方法并尝试读取 ZipInputStream 我得到异常:
Not a valid BZip2 stream. byte 1, expected '90', got '107'
в Ionic.BZip2.BZip2InputStream.CheckMagicChar(Char expected, Int32 position)
в Ionic.BZip2.BZip2InputStream.init()
в Ionic.BZip2.BZip2InputStream..ctor(Stream input, Boolean leaveOpen)
в Ionic.Zip.ZipEntry.GetExtractDecompressor(Stream input2)
в Ionic.Zip.ZipEntry.InternalOpenReader(String password)
в Ionic.Zip.ZipInputStream.SetupStream()
в Ionic.Zip.ZipInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
в System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
в System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
有什么想法吗?
【问题讨论】:
标签: c# aes dotnetzip bzip2 zipinputstream