base64的特点:编码之后,只有64个字符:a~z,A~Z,0~9,/,+.在加上一个辅助字符=.总共65个字符组成.
文件
一,前提
1.有一个demo.json文件.
2.在终端操作.
二,编码
1.打开终端,cd到demo.json文件的当前文件夹.
2.输入命令:base64 demo.json -o demo64.txt,然后回车.
3.open demo64.txt.
三,解码
1.打开终端,cd到demo64.txt文件的当前文件夹.
2.输入命令:base64 -D demo64.txt -o demoNew.json,然后回车.
3.open demoNew.json,总结:demoNew.json与demo.json的文件内容是一样的.
字符串
一,编码
输入:echo -n “Man” | base64
输出: TWFu
二,解码:
输入:echo -n “TWFu” | base64 -D
输出: Man