Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvrsh3ll/04c1d7baff869cd4619548bf1cda36e0 to your computer and use it in GitHub Desktop.
Save rvrsh3ll/04c1d7baff869cd4619548bf1cda36e0 to your computer and use it in GitHub Desktop.
Read file, gzip and convert to base64.
$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