本文整理汇总了C#中ICSharpCode.SharpZipLib.Encryption.PkzipClassicManaged.CreateEncryptor方法的典型用法代码示例。如果您正苦于以下问题:C# PkzipClassicManaged.CreateEncryptor方法的具体用法?C# PkzipClassicManaged.CreateEncryptor怎么用?C# PkzipClassicManaged.CreateEncryptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.SharpZipLib.Encryption.PkzipClassicManaged
的用法示例。
在下文中一共展示了PkzipClassicManaged.CreateEncryptor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndInitEncryptionStream
Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry)
{
CryptoStream result = null;
if ( (entry.Version < ZipConstants.VersionStrongEncryption)
|| (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) {
PkzipClassicManaged classicManaged = new PkzipClassicManaged();
OnKeysRequired(entry.Name);
if (HaveKeys == false) {
throw new ZipException("No password available for encrypted stream");
}
// Closing a CryptoStream will close the base stream as well so wrap it in an UncompressedStream
// which doesnt do this.
result = new CryptoStream(new UncompressedStream(baseStream),
classicManaged.CreateEncryptor(key, null), CryptoStreamMode.Write);
if ( (entry.Crc < 0) || (entry.Flags & 8) != 0) {
WriteEncryptionHeader(result, entry.DosTime << 16);
}
else {
WriteEncryptionHeader(result, entry.Crc);
}
}
return result;
}
示例2: InitializePassword
/// <summary>
/// Initializes encryption keys based on given password
/// </summary>
/// <param name="password">The password.</param>
protected void InitializePassword(string password)
{
#if NETCF_1_0
keys = new uint[] {
0x12345678,
0x23456789,
0x34567890
};
byte[] rawPassword = ZipConstants.ConvertToArray(password);
for (int i = 0; i < rawPassword.Length; ++i) {
UpdateKeys((byte)rawPassword[i]);
}
#else
PkzipClassicManaged pkManaged = new PkzipClassicManaged();
byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));
cryptoTransform_ = pkManaged.CreateEncryptor(key, null);
#endif
}
示例3: CreateAndInitEncryptionStream
Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry)
{
CryptoStream result = null;
if (entry.Version < ZipConstants.VERSION_STRONG_ENCRYPTION
|| (entry.Flags & (int)GeneralBitFlags.StrongEncryption) == 0) {
PkzipClassicManaged classicManaged = new PkzipClassicManaged();
OnKeysRequired(entry.Name);
if (HaveKeys == false) {
throw new ZipException("No password available for encrypted stream");
}
result = new CryptoStream(baseStream, classicManaged.CreateEncryptor(key, iv), CryptoStreamMode.Write);
if (entry.Crc < 0 || (entry.Flags & 8) != 0) {
WriteEncryptionHeader(result, entry.DosTime << 16);
}
else {
WriteEncryptionHeader(result, entry.Crc);
}
}
return result;
}
示例4: InitializePassword
/// <summary>
/// Initializes encryption keys based on given <paramref name="password"/>.
/// </summary>
/// <param name="password">The password.</param>
protected void InitializePassword(string password)
{
PkzipClassicManaged pkManaged = new PkzipClassicManaged();
byte[] key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(password));
cryptoTransform_ = pkManaged.CreateEncryptor(key, null);
}
示例5: CreateAndInitEncryptionStream
private Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry)
{
CryptoStream stream = null;
if ((entry.Version < 50) || ((entry.Flags & 0x40) == 0))
{
PkzipClassicManaged managed = new PkzipClassicManaged();
this.OnKeysRequired(entry.Name);
if (!this.HaveKeys)
{
throw new ZipException("No password available for encrypted stream");
}
stream = new CryptoStream(new UncompressedStream(baseStream), managed.CreateEncryptor(this.key, null), CryptoStreamMode.Write);
if ((entry.Crc < 0L) || ((entry.Flags & 8) != 0))
{
WriteEncryptionHeader(stream, entry.DosTime << 0x10);
return stream;
}
WriteEncryptionHeader(stream, entry.Crc);
}
return stream;
}