shell中base64编解码的使用

base64编解码的使用

base64编码

base64 file
功能:从指定的文件file中读取数据,编码为base64的字符串然后输出;

echo “string” | base64
功能:将字符串string+换行编码为base64的字符串然后输出;

echo -n “string” | base64
功能:将字符串string编码为base64的字符串然后输出;

base64解码

base64 -d file
功能:从指定的文件file中读取已经过base64编码的数据,然后进行解码,并输出解码后的字符串;

echo “str” | base64 -d
功能:对base64编码的字符串str和空行进行解码,然后将解码后的字符串输出;

echo -n “str” | base -d
功能:对base64编码的字符串str进行解码,然后将解码后的字符串输出;

注意
在Ubuntu下base64解码时键入的是-d,而在mac上解码时键入的是-D;
具体情况可以在相应的平台键入下面的指令进行查看:

➜  ~ base64 --help
Usage: base64 [OPTION]... [FILE]
Base64 encode or decode FILE, or standard input, to standard output.

Mandatory arguments to long options are mandatory for short options too.
  -d, --decode          decode data
  -i, --ignore-garbage  when decoding, ignore non-alphabet characters
  -w, --wrap=COLS       wrap encoded lines after COLS character (default 76).
                          Use 0 to disable line wrapping

      --help     display this help and exit
      --version  output version information and exit

With no FILE, or when FILE is -, read standard input.

The data are encoded as described for the base64 alphabet in RFC 3548.
When decoding, the input may contain newlines in addition to the bytes of
the formal base64 alphabet.  Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'base64 invocation'
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Erice_s

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值