Skip to content

Instantly share code, notes, and snippets.

@vortexau
Last active May 13, 2024 07:53
Show Gist options
  • Save vortexau/13de5b6f9e46cf419f1540753c573206 to your computer and use it in GitHub Desktop.
Save vortexau/13de5b6f9e46cf419f1540753c573206 to your computer and use it in GitHub Desktop.
Powershell to decompress DEFLATE data
$base64data = "insert compressed and base64 data here"
$data = [System.Convert]::FromBase64String($base64data)
$ms = New-Object System.IO.MemoryStream
$ms.Write($data, 0, $data.Length)
$ms.Seek(0,0) | Out-Null
$sr = New-Object System.IO.StreamReader(New-Object System.IO.Compression.DeflateStream($ms, [System.IO.Compression.CompressionMode]::Decompress))
while ($line = $sr.ReadLine()) {
$line
}
@Luiz-Monad
Copy link

also, if you are trying to decompress things compressed by zlib, you probably want to use ZLibStream instead of DeflateStream. Now, if you're trying to decompress an actual ZipFile, the process is different, those are for bare streams.

@pzarczyn
Copy link

Thank you @Luiz-Monad, this helped me a lot and works now.
Have a great day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment