Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
/ PS-GZip Public archive

compression and expansion of strings and files using the GZipStream Class with PowerShell

License

Notifications You must be signed in to change notification settings

santisq/PS-GZip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

PS-Gzip Module

Description

PS-GZip Module is a set of PowerShell functions designed to compress and expand strings and files using the GZipStream Class.

See the Docs folder for details on each function.

Requirements

Requires PowerShell 5.1 and above.

Examples

  • Compressing a String
PS /> Compress-GzipString 'Hello world!'

H4sIAAAAAAAACvNIzcnJVyjPL8pJUQQAlRmFGwwAAAA=
  • Expanding a Base64 GZip compressed String
PS /> Expand-GzipString H4sIAAAAAAAACvNIzcnJVyjPL8pJUQQAlRmFGwwAAAA=

Hello world!
# Thanks https://baconipsum.com/ :D
$loremIp = Invoke-RestMethod 'https://baconipsum.com/api/?type=all-meat&paras=100&start-with-lorem=1&format=text'
$compressedLoremIp = Compress-GzipString $loremIp
@{ Expanded = $loremIp; Compressed = $compressedLoremIp }.GetEnumerator() |
  Select-Object @{ N='Type'; E={ $_.Key }}, @{ N='Length'; E={ $_.Value.Length }}

Type       Length
----       ------
Compressed  13624
Expanded    45033

(Expand-GzipString $compressedLoremIp) -eq $loremIp # => # Should be True
  • Compressing a File
PS /> $temp = New-TemporaryFile
PS /> 'Hello world!' | Set-Content $temp
PS /> Compress-GzipFile $temp -DestinationPath test.gz
PS /> Remove-Item $temp
  • Expanding a Gzip compressed File
PS /> Get-Item test.gz | Expand-GzipFile

Hello world!

PS /> Remove-Item test.gz

About

compression and expansion of strings and files using the GZipStream Class with PowerShell

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published