Linux常用命令-base64

命令

base64

描述

base64 encode/decode data and print to standard output
base64加解密文件

用法

1
base64 [OPTION]... [FILE]

选项

-d 解密文件

注意

支持多次加密

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 加解密字符串
$ echo aaa| base64
YWFhCg==
$ echo YWFhCg== |base64 -d
aaa
# 执行两次加密
$ echo aaa | base64|base64
WVdGaENnPT0K
$ echo WVdGaENnPT0K |base64 -d|base64 -d
aaa
# 注意echo默认输出最后是有一个换行符的,可以加-n选项排除
$ echo aaa | base64
YWFhCg==
$ echo -n aaa | base64
YWFh
$ echo YWFh | base64 -d
aaa

# 加解密文件
$ echo aaa > file
$ base64 file
YWFhCg==
$ base64 file > file1
$ more file1
YWFhCg==
$ base64 -d file1
aaa
$ base64 -d file1 > file2
$ more file2
aaa