提交 56c44d6b 编写于 作者: B baiy 提交者: ninecents

添加 jwt 解码功能 #52

上级 fe55b333
.DS_Store .DS_Store
/node_modules /node_modules
/temp_release
/desktop/node_modules /desktop/node_modules
/dist /dist
/public/manifest.json /public/manifest.json
/public/plugin.json /public/plugin.json
/public/README.md /public/README.md
/id_rsa.pem /id_rsa.pem
/public/_locales
# local env files # local env files
.env.local .env.local
...@@ -27,4 +25,3 @@ yarn-error.log* ...@@ -27,4 +25,3 @@ yarn-error.log*
*.sln *.sln
*.sw* *.sw*
test.js test.js
/public/background.js
...@@ -62,6 +62,7 @@ npm run serve -adapter=utools ...@@ -62,6 +62,7 @@ npm run serve -adapter=utools
|JSON转实体类|`Java`, `C#`, `Go`, `Dart`|√| |JSON转实体类|`Java`, `C#`, `Go`, `Dart`|√|
|ascii编码转换|`十进制`, `十六进制`, `八进制`, `二进制`, `字符串`|√| |ascii编码转换|`十进制`, `十六进制`, `八进制`, `二进制`, `字符串`|√|
|变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√| |变量名格式转换|`Var Name`, `var-name`, `VAR_NAME`, `VarName`, `varName`, `var_name`, `var name`|√|
|jwt解码|`header`, `payload`|√|
## 第三方开源库 ## 第三方开源库
项目诞生离不开这些优秀的开源程序 项目诞生离不开这些优秀的开源程序
...@@ -96,6 +97,7 @@ npm run serve -adapter=utools ...@@ -96,6 +97,7 @@ npm run serve -adapter=utools
- [vue-codemirror](https://www.npmjs.com/package/vue-codemirror) - [vue-codemirror](https://www.npmjs.com/package/vue-codemirror)
- [sm-crypto](https://github.com/JuneAndGreen/sm-crypto) - [sm-crypto](https://github.com/JuneAndGreen/sm-crypto)
- [camelcaseplugin](https://github.com/netnexus/camelcaseplugin) - [camelcaseplugin](https://github.com/netnexus/camelcaseplugin)
- [jwt-decode](https://www.npmjs.com/package/jwt-decode)
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢 > 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
......
{ {
"name": "c-tool", "name": "c-tool",
"version": "1.6.1", "version": "1.6.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -6852,6 +6852,11 @@ ...@@ -6852,6 +6852,11 @@
"resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.3.1.tgz", "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.3.1.tgz",
"integrity": "sha512-zCTP6Qd/WwjrpuHFkJuXc5opRdKprUr7eI7+JCCtcetThJt45qptu82MWQ+eET+FtDrMo7+BYjo3iD0XIq1L9Q==" "integrity": "sha512-zCTP6Qd/WwjrpuHFkJuXc5opRdKprUr7eI7+JCCtcetThJt45qptu82MWQ+eET+FtDrMo7+BYjo3iD0XIq1L9Q=="
}, },
"jwt-decode": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz",
"integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
},
"killable": { "killable": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
......
...@@ -39,6 +39,7 @@ const tool = [ ...@@ -39,6 +39,7 @@ const tool = [
{'name': 'jsonToObject', 'title': 'JSON转实体类', 'cat': ['conversion', 'serialize']}, {'name': 'jsonToObject', 'title': 'JSON转实体类', 'cat': ['conversion', 'serialize']},
{'name': 'ascii', 'title': 'ascii转换', 'cat': ['conversion']}, {'name': 'ascii', 'title': 'ascii转换', 'cat': ['conversion']},
{'name': 'variableConversion', 'title': '变量名转换', 'cat': ['conversion']}, {'name': 'variableConversion', 'title': '变量名转换', 'cat': ['conversion']},
{'name': 'jwt', 'title': 'jwt解码', 'cat': ['conversion']},
] ]
// 工具类功能配置 // 工具类功能配置
...@@ -52,7 +53,8 @@ const feature = { ...@@ -52,7 +53,8 @@ const feature = {
const utools = { const utools = {
keyword: { keyword: {
hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'], hash: ['md5', 'sha1', 'sha256', 'sha512', 'sm3'],
encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'] encrypt: ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2'],
jwt: ['jwtDecode']
}, },
cmds: { cmds: {
timestamp: [ timestamp: [
......
...@@ -101,6 +101,10 @@ const routes = [ ...@@ -101,6 +101,10 @@ const routes = [
{ {
path: '/tool/variableConversion', path: '/tool/variableConversion',
component: r => require(['./views/tool/variableConversion.vue'], r) component: r => require(['./views/tool/variableConversion.vue'], r)
},
{
path: '/tool/jwt',
component: r => require(['./views/tool/jwt.vue'], r)
} }
] ]
......
<template> <template>
<heightResize @resize="resize"> <div>
<Row :gutter="10"> <Input v-model="current.input" :rows="7" type="textarea" placeholder="内容"></Input>
<Col span="12"> <option-block>
<input-block top="4px"> <FormItem>
<code-editor :height="editorheight" :placeholder="$t('jwt_input')" hideLineNumbers v-model="current.input"></code-editor> <ButtonGroup>
<template slot="extra"> <Button type="primary" @click="handle('decode')">解码</Button>
<Checkbox v-model="current.header">header</Checkbox> </ButtonGroup>
<Checkbox v-model="current.payload">payload</Checkbox> </FormItem>
</template> <FormItem>
</input-block> <Checkbox v-model="current.header">header</Checkbox>
</Col> <Checkbox v-model="current.payload">payload</Checkbox>
<Col span="12"> </FormItem>
<code-editor :height="editorheight" :placeholder="$t('jwt_output')" :value="output" language="json"></code-editor> </option-block>
</Col> <Input v-model="current.output" :rows="7" type="textarea" placeholder="结果"></Input>
</Row> </div>
</heightResize>
</template> </template>
<script> <script>
import jwtDecode from "jwt-decode" import jwtDecode from "jwt-decode"
import codeEditor from "./components/codeEditor";
import jsonFormatter from "./library/formatter/json";
import heightResize from "./components/heightResize";
export default { export default {
components: {
codeEditor,
heightResize
},
created() { created() {
this.$initToolData('input') this.current = Object.assign(this.current, this.$getToolData("input"))
}, },
computed: { methods: {
output() { handle(v) {
if(!this.current.input.trim()){ if (this.current.input) {
return "" try {
} let data = {};
try { if (this.current.header) {
let data = {}; data.header = jwtDecode(this.current.input, {header: true})
if (this.current.header) { }
data.header = jwtDecode(this.current.input, {header: true}) if (this.current.payload) {
} data.payload = jwtDecode(this.current.input)
if (this.current.payload) { }
data.payload = jwtDecode(this.current.input) this.current.output = JSON.stringify(
Object.keys(data).length === 1 ? data[Object.keys(data)[0]] : data,
null,4
);
this.current.operation = v;
this.$clipboardCopy(this.current.output);
this.$saveToolData(this.current);
} catch (e) {
this.$Message.error("解码失败")
console.log(e)
} }
this.$saveToolData(this.current);
return jsonFormatter.objectBeautify(
Object.keys(data).length === 1 ? data[Object.keys(data)[0]] : data,
);
} catch (e) {
return this.$t('jwt_decode_fail',[e.message])
} }
} }
}, },
methods:{
resize(height){
this.editorheight = height+"px"
}
},
data() { data() {
return { return {
current: { current: {
input: "", input: "",
output: "",
header: false, header: false,
payload: true, payload: true,
}, operation: ""
editorheight:"100%", }
} }
}, },
} }
</script> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册