2022-07-15 22:37:32 +08:00
|
|
|
# base64
|
2021-01-07 19:42:30 +08:00
|
|
|
|
2022-07-15 22:37:32 +08:00
|
|
|
::: tip
|
|
|
|
base64 编码转换,和 linux 里的 base64 命令类似。
|
|
|
|
:::
|
2021-01-07 19:42:30 +08:00
|
|
|
|
2022-08-09 18:42:39 +08:00
|
|
|
## 对文件进行 base64 编码
|
2021-01-07 19:42:30 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
[arthas@70070]$ echo 'abc' > /tmp/test.txt
|
|
|
|
[arthas@70070]$ cat /tmp/test.txt
|
|
|
|
abc
|
|
|
|
|
|
|
|
[arthas@70070]$ base64 /tmp/test.txt
|
|
|
|
YWJjCg==
|
|
|
|
```
|
|
|
|
|
2022-08-09 18:42:39 +08:00
|
|
|
## 对文件进行 base64 编码并把结果保存到文件里
|
2021-01-07 19:42:30 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ base64 --input /tmp/test.txt --output /tmp/result.txt
|
|
|
|
```
|
|
|
|
|
2022-08-09 18:42:39 +08:00
|
|
|
## 用 base64 解码文件
|
2021-01-07 19:42:30 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
$ base64 -d /tmp/result.txt
|
|
|
|
abc
|
|
|
|
```
|
|
|
|
|
2022-08-09 18:42:39 +08:00
|
|
|
## 用 base64 解码文件并保存结果到文件里
|
2021-01-07 19:42:30 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ base64 -d /tmp/result.txt --output /tmp/bbb.txt
|
|
|
|
```
|