Skip to content

Instantly share code, notes, and snippets.

@daejinseok
Created June 17, 2021 01:37
Show Gist options
  • Save daejinseok/d7cf53c1b00d19ec72d10989be6c5111 to your computer and use it in GitHub Desktop.
Save daejinseok/d7cf53c1b00d19ec72d10989be6c5111 to your computer and use it in GitHub Desktop.
binary 파일을 base64 파일로 변환하고 다시 binary파일로 변경
# encode from binary file to base64txt
$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
$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