一、base64加密
格式:base64 从标准输入中读取数据,按Ctrl+D结束输入。将输入的内容编码为base64字符串输出。
格式:echo "str" | base64
将字符串str
+换行 编码为base64字符串输出。
格式:echo -n "str" | base64
将字符串str编码为base64字符串输出。注意与上面的差别。
格式:base64 file
从指定的文件file中读取数据,编码为base64字符串输出。
二、base64解密
格式:base64 -d
从标准输入中读取已经进行base64编码的内容,解码输出。
格式:base64 -d-i
从标准输入中读取已经进行base64编码的内容,解码输出。加上-i参数,忽略非字母表字符,比如换行符。
man base64 写道
-i, --ignore-garbage
When decoding, ignore non-alphabet characters.
use --ignore-garbage to attempt to recover from non-alphabet characters (such as newlines) in the encoded stream.
格式:echo "str" | base64 -d
将base64编码的字符串str+换行 解码输出。
格式:echo -n "str" | base64 -d
将base64编码的字符串str解码输出。 注意与上面的差别。
格式:base64 -d file
从指定的文件file中读取base64编码的内容,解码输出。
参考资料:
http://codingstandards.iteye.com/blog/934928