エンコード
base64
コマンドを使用することでエンコードできます。
$ echo "sample" | base64
c2FtcGxlCg==
base64 -i image.jpg -o output.txt
デコード
デコードするには-d
を使用します。
$ echo "c2FtcGxlCg==" | base64 -d
sample
base64 -d -i sample.txt -o image.jpg
オプション
$ base64 --help
Usage: base64 [-Ddh] [-b num] [-i in_file] [-o out_file]
-b, --break break encoded output up into lines of length num
-D, -d, --decode decode input
-h, --help display this message
-i, --input input file (default: "-" for stdin)
-o, --output output file (default: "-" for stdout)