가끔씩 쓰는데 명령어가 헷갈릴 때가 있어 남겨둡니다.

bash 쉘에서 base64 툴 이용 시.

# base64 인코딩
echo "test" | base64

# base64 디코딩
echo "dGVzdAo=" | base64 -d

#  without new line
echo -n "test" | base64 -w 0

powershell에서 base64 툴 이용 시

# base64 인코딩
echo "test" | %{ [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($_)) }

# base64 디코딩
echo "dGVzdA==" | %{ [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) }

# %{ } 는 foreach의 shorthand다.

+ Recent posts