Skip to content

Commit bcb7810

Browse files
committed
doneeeee
1 parent f9b2722 commit bcb7810

7 files changed

Lines changed: 68 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,35 @@
22

33
## 12/13/2025
44

5-
- Zip entries are now created directly from `ICSharpCode.SharpZipLib.Zip.ZipEntry`.
6-
This adds the following new properties to `ZipEntryBase`:
7-
- `IsEncrypted` (`bool`)
8-
- `AESKeySize` (`int`)
9-
- `CompressionMethod` (`ICSharpCode.SharpZipLib.Zip.CompressionMethod`)
10-
- `Comment` (`string`)
5+
- **Native Zip Entry Objects**
116

12-
- `Get-ZipEntryContent` and `Expand-ZipEntry` now support reading and extracting encrypted entries.
13-
A new parameter has been added to both cmdlets:
7+
Zip entries returned by `Get-ZipEntry` (and created by `New-ZipEntry`) are now backed directly by `ICSharpCode.SharpZipLib.Zip.ZipEntry`.
8+
This exposes additional useful properties on `ZipEntryBase` derived objects:
9+
- `IsEncrypted` (`bool`) – Indicates whether the entry is encrypted.
10+
- `AESKeySize` (`int`) – AES key size (0, 128, 192, or 256) if AES encryption is used.
11+
- `CompressionMethod` (`ICSharpCode.SharpZipLib.Zip.CompressionMethod`) – The actual compression method used.
12+
- `Comment` (`string`) – The entry comment.
13+
- `Crc` (`long`) – Cyclic redundancy check.
14+
15+
- **Support for Encrypted Zip Entries**
16+
17+
`Get-ZipEntryContent` and `Expand-ZipEntry` now fully support reading and extracting password-protected entries.
18+
A new common parameter has been added to both cmdlets:
1419

1520
```powershell
1621
-Password <SecureString>
1722
```
1823

19-
If an entry is encrypted and no password is provided, the cmdlets will securely prompt for one.
24+
- If an entry is encrypted and no password is provided, the cmdlets will securely prompt for one.
25+
- Examples and detailed guidance for handling encrypted entries have been added to the help documentation.
26+
27+
- **Documentation Improvements**
28+
29+
All cmdlet help files have been reviewed and updated for consistency and clarity.
30+
Significant enhancements to `Get-ZipEntryContent` and `Expand-ZipEntry` help:
31+
- Added dedicated examples demonstrating password-protected entry handling.
32+
- Updated parameter descriptions and notes for the new `-Password` parameter.
33+
- Improved phrasing, removed outdated example output, and ensured uniform formatting across the module.
2034

2135
## 07/02/2025
2236

module/PSCompression.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
RootModule = 'PSCompression.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '3.0.1'
14+
ModuleVersion = '3.1.0'
1515

1616
# Supported PSEditions
1717
# CompatiblePSEditions = @()

src/PSCompression/Abstractions/TarEntryBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal FileSystemInfo ExtractTo(
3636
}
3737

3838
FileInfo file = new(destination);
39-
file.Directory?.Create();
39+
file.Directory!.Create();
4040

4141
using FileStream destStream = file.Open(
4242
overwrite ? FileMode.Create : FileMode.CreateNew,

src/PSCompression/Abstractions/ZipEntryBase.SharpZipLib.Zip.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public abstract partial class ZipEntryBase(ZipEntry entry, string source)
2828

2929
public string Comment { get; } = entry.Comment ?? string.Empty;
3030

31+
public long Crc { get; } = entry.Crc;
32+
3133
protected ZipEntryBase(ZipEntry entry, Stream? stream)
3234
: this(entry, $"InputStream.{Guid.NewGuid()}")
3335
{

src/PSCompression/AlgorithmMappings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ internal static class AlgorithmMappings
3131
};
3232

3333
internal static Algorithm Parse(string path) =>
34-
_mappings.TryGetValue(Path.GetExtension(path), out Algorithm value)
35-
? value : Algorithm.none;
34+
_mappings.TryGetValue(Path.GetExtension(path), out Algorithm value) ? value : Algorithm.none;
3635
}

tests/ArchiveEntryManagementCommands.tests.ps1

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Describe 'Archive Entry Management Commands' {
3232
Compress-TarArchive @compressTarArchiveSplat
3333
}
3434

35-
$zip, $file, $uri, $tarArchives, $itemCounts, $totalCount | Out-Null
35+
$encryptedZip = Get-Item $PSScriptRoot/../assets/helloworld.zip
36+
$zip, $file, $uri, $tarArchives, $itemCounts, $totalCount, $encryptedZip | Out-Null
3637
}
3738

3839
Context 'New-ZipEntry' -Tag 'New-ZipEntry' {
@@ -356,6 +357,20 @@ Describe 'Archive Entry Management Commands' {
356357
{ $zip | Get-ZipEntry -Type Directory | Get-ZipEntry } |
357358
Should -Throw
358359
}
360+
361+
It 'Can read encrypted entries' {
362+
$passw = ConvertTo-SecureString 'test' -AsPlainText -Force
363+
364+
Use-Object ($stream = $encryptedZip.OpenRead()) {
365+
$stream | Get-ZipEntry -Type Archive |
366+
Get-ZipEntryContent -Password $passw |
367+
Should -BeExactly 'hello world!'
368+
}
369+
370+
$encryptedZip | Get-ZipEntry -Type Archive |
371+
Get-ZipEntryContent -Password $passw |
372+
Should -BeExactly 'hello world!'
373+
}
359374
}
360375

361376
Context 'Get-TarEntryContent' -Tag 'Get-TarEntryContent' {
@@ -680,6 +695,26 @@ Describe 'Archive Entry Management Commands' {
680695
Get-ChildItem -LiteralPath $destination -Recurse -File |
681696
ForEach-Object { $_ | Get-Content | Should -BeExactly $content }
682697
}
698+
699+
It 'Can extract an encrypted entry' {
700+
$passw = ConvertTo-SecureString 'test' -AsPlainText -Force
701+
$dest = Join-Path $TestDrive encryptedTestFolder
702+
Use-Object ($stream = $encryptedZip.OpenRead()) {
703+
$info = $stream | Get-ZipEntry -Type Archive |
704+
Expand-ZipEntry -Password $passw -Destination $dest -PassThru
705+
706+
$info | Should -BeOfType ([FileInfo])
707+
Get-Content $info.FullName | Should -BeExactly 'hello world!'
708+
$info.Delete()
709+
}
710+
711+
$info = $encryptedZip | Get-ZipEntry |
712+
Expand-ZipEntry -Password $passw -Destination $dest -PassThru
713+
714+
$info | Should -BeOfType ([FileInfo])
715+
Get-Content $info.FullName | Should -BeExactly 'hello world!'
716+
$info.Delete()
717+
}
683718
}
684719

685720
Context 'Expand-TarEntry' -Tag 'Expand-TarEntry' {

tests/ZipEntryBase.tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Describe 'ZipEntryBase Class' {
7676
($zip | Get-ZipEntry).CompressionRatio | Should -BeOfType ([string])
7777
}
7878

79+
It 'Has a Crc Property' {
80+
($zip | Get-ZipEntry).Crc | Should -BeOfType ([long])
81+
}
82+
7983
It 'Can remove an entry in the source zip' {
8084
{ $zip | Get-ZipEntry | ForEach-Object Remove } |
8185
Should -Not -Throw

0 commit comments

Comments
 (0)