Last active
September 6, 2021 14:38
-
-
Save FrankSpierings/cbf9e86c3055dea3477e393742a0dedc to your computer and use it in GitHub Desktop.
Read file, gzip and convert to base64.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filepath = "/etc/passwd" | |
$fs = New-Object IO.FileStream($filepath, [System.IO.FileMode]::Open) | |
$ms = New-Object System.IO.MemoryStream; | |
$gzs = New-Object System.IO.Compression.GzipStream($ms, [System.IO.Compression.CompressionMode]::Compress); | |
$fs.CopyTo($gzs); | |
$fs.Close(); | |
$gzs.Close(); | |
$ms.Close(); | |
[System.Convert]::ToBase64String($ms.ToArray()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment