Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Created July 14, 2017 04:15
Show Gist options
  • Save t2psyto/f5453707d2658173715f49293d096fe5 to your computer and use it in GitHub Desktop.
Save t2psyto/f5453707d2658173715f49293d096fe5 to your computer and use it in GitHub Desktop.
powershell oneliner for encode/decode base64 to file
# encode from binary file to base64txt
powershell -C "& {$outpath = (Join-Path (pwd) 'out_base64.txt'); $inpath = (Join-Path (pwd) 'data.jpg'); [IO.File]::WriteAllText($outpath, ([convert]::ToBase64String(([IO.File]::ReadAllBytes($inpath)))))}"
# decode from base64txt to binary file
powershell -C "& {$outpath = (Join-Path (pwd) 'outdata2.jpg'); $inpath = (Join-Path (pwd) 'out_base64.txt'); [IO.File]::WriteAllBytes($outpath, ([convert]::FromBase64String(([IO.File]::ReadAllText($inpath)))))}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment