mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
fix #1646
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
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
|
||||
```
|
||||
Reference in New Issue
Block a user