diff --git a/core/src/main/java/com/taobao/arthas/core/command/model/Base64Model.java b/core/src/main/java/com/taobao/arthas/core/command/model/Base64Model.java new file mode 100644 index 000000000..11852a940 --- /dev/null +++ b/core/src/main/java/com/taobao/arthas/core/command/model/Base64Model.java @@ -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; + } +} diff --git a/core/src/main/java/com/taobao/arthas/core/command/view/Base64View.java b/core/src/main/java/com/taobao/arthas/core/command/view/Base64View.java new file mode 100644 index 000000000..e6dee743d --- /dev/null +++ b/core/src/main/java/com/taobao/arthas/core/command/view/Base64View.java @@ -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 { + + @Override + public void draw(CommandProcess process, Base64Model result) { + String content = result.getContent(); + if (content != null) { + process.write(content); + } + process.write("\n"); + } + +} diff --git a/site/src/site/sphinx/base64.md b/site/src/site/sphinx/base64.md new file mode 100644 index 000000000..1383f9dcd --- /dev/null +++ b/site/src/site/sphinx/base64.md @@ -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 +``` diff --git a/site/src/site/sphinx/en/base64.md b/site/src/site/sphinx/en/base64.md new file mode 100644 index 000000000..cd85bdb50 --- /dev/null +++ b/site/src/site/sphinx/en/base64.md @@ -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 +```