提交 5a8d11c8 编写于 作者: 横云断岭's avatar 横云断岭

fix #1646

上级 aa396f8f
package com.taobao.arthas.core.command.model;
/**
*
* @author hengyunabc 2021-01-05
*
*/
public class Base64Model extends ResultModel {
private String content;
public Base64Model() {
}
public Base64Model(String content) {
this.content = content;
}
@Override
public String getType() {
return "base64";
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
package com.taobao.arthas.core.command.view;
import com.taobao.arthas.core.command.model.Base64Model;
import com.taobao.arthas.core.shell.command.CommandProcess;
/**
*
* @author hengyunabc 2021-01-05
*
*/
public class Base64View extends ResultView<Base64Model> {
@Override
public void draw(CommandProcess process, Base64Model result) {
String content = result.getContent();
if (content != null) {
process.write(content);
}
process.write("\n");
}
}
base64
===
> base64编码转换,和linux里的 base64 命令类似。
### 对文件进行 base64 编码
```bash
[arthas@70070]$ echo 'abc' > /tmp/test.txt
[arthas@70070]$ cat /tmp/test.txt
abc
[arthas@70070]$ base64 /tmp/test.txt
YWJjCg==
```
### 对文件进行 base64 编码并把结果保存到文件里
```bash
$ base64 --input /tmp/test.txt --output /tmp/result.txt
```
### 用 base64 解码文件
```
$ base64 -d /tmp/result.txt
abc
```
### 用 base64 解码文件并保存结果到文件里
```bash
$ base64 -d /tmp/result.txt --output /tmp/bbb.txt
```
base64
===
> Encode and decode using Base64 representation.
### Encode to base64
```bash
[arthas@70070]$ echo 'abc' > /tmp/test.txt
[arthas@70070]$ cat /tmp/test.txt
abc
[arthas@70070]$ base64 /tmp/test.txt
YWJjCg==
```
### Encode to base64 and save output to file
```bash
$ base64 --input /tmp/test.txt --output /tmp/result.txt
```
### Decode from base64
```
$ base64 -d /tmp/result.txt
abc
```
### Decode from base64 and save output to file
```bash
$ base64 -d /tmp/result.txt --output /tmp/bbb.txt
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册