base64编码的字符串用的挺多的……
编码
1. 从标准输入中读取数据,按Ctrl+D结束输入。将输入的内容编码为base64字符串输出。
base64
2. 将字符串str+换行 编码为base64字符串输出。
echo "str" | base64
3. 将字符串str编码为base64字符串输出。注意与上面的差别。
echo -n "str" | base64
#echo -n 即为不输出换行
4. 从指定的文件file中读取数据,编码为base64字符串输出。
base64 file
解码
1. 从标准输入中读取已经进行base64编码的内容,解码输出。
base64 -d
2. 从标准输入中读取已经进行base64编码的内容,解码输出。加上-i参数,忽略非字母表字符,比如换行符。
base64 -d -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.
3. 将base64编码的字符串str+换行 解码输出。
echo "str" | base64 -d
4. 将base64编码的字符串str解码输出。 注意与上面的差别。
echo -n "str" | base64 -d
5. 从指定的文件file中读取base64编码的内容,解码输出。
base64 -d file
使用示例
参考:http://codingstandards.iteye.com/blog/934928
本文被阅读了:1,535次