Skip to content

Commit

Permalink
Move the Password property from DeflaterOutputStream into ZipOutputSt…
Browse files Browse the repository at this point in the history
…ream
  • Loading branch information
Numpsy committed Mar 14, 2021
1 parent 7ed87d1 commit a723764
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Expand Up @@ -153,38 +153,13 @@ public bool CanPatchEntries

#region Encryption

private string password;

private ICryptoTransform cryptoTransform_;

/// <summary>
/// Returns the 10 byte AUTH CODE to be appended immediately following the AES data stream.
/// </summary>
protected byte[] AESAuthCode;

/// <summary>
/// Get/set the password used for encryption.
/// </summary>
/// <remarks>When set to null or if the password is empty no encryption is performed</remarks>
public string Password
{
get
{
return password;
}
set
{
if ((value != null) && (value.Length == 0))
{
password = null;
}
else
{
password = value;
}
}
}

/// <summary>
/// Encrypt a block of data
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs
Expand Up @@ -154,6 +154,29 @@ public UseZip64 UseZip64
/// </summary>
public INameTransform NameTransform { get; set; } = new PathTransformer();

/// <summary>
/// Get/set the password used for encryption.
/// </summary>
/// <remarks>When set to null or if the password is empty no encryption is performed</remarks>
public string Password
{
get
{
return password;
}
set
{
if ((value != null) && (value.Length == 0))
{
password = null;
}
else
{
password = value;
}
}
}

/// <summary>
/// Write an unsigned short in little endian byte order.
/// </summary>
Expand Down Expand Up @@ -1010,6 +1033,11 @@ public override void Flush()
// NOTE: Setting the size for entries before they are added is the best solution!
private UseZip64 useZip64_ = UseZip64.Dynamic;

/// <summary>
/// The password to use when encrypting archive entries.
/// </summary>
private string password;

#endregion Instance Fields
}
}

0 comments on commit a723764

Please sign in to comment.