提交 0e4c3d4e 编写于 作者: B baiy 提交者: ninecents

#60 添加 hex string 转换

上级 704fc15b
...@@ -40,7 +40,7 @@ npm run serve -adapter=utools ...@@ -40,7 +40,7 @@ npm run serve -adapter=utools
|---|---|---| |---|---|---|
|哈希|`md5`, `sha1`, `sha256`, `sha512`,`sm3`|√| |哈希|`md5`, `sha1`, `sha256`, `sha512`,`sm3`|√|
|加密/解密|`AES`,`DES`,`RC4`,`Rabbit`,`TripleDes`,`sm2`|√| |加密/解密|`AES`,`DES`,`RC4`,`Rabbit`,`TripleDes`,`sm2`|√|
|BASE64编码|`加密`,`解密`|√| |BASE64编码|`加密`,`解密`,`支持文件`|√|
|URL编码|`编码`,`解码`|√| |URL编码|`编码`,`解码`|√|
|时间戳|双向转换|√| |时间戳|双向转换|√|
|二维码|`生成`,`解析`|√| |二维码|`生成`,`解析`|√|
...@@ -63,6 +63,7 @@ npm run serve -adapter=utools ...@@ -63,6 +63,7 @@ npm run serve -adapter=utools
|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`|√| |jwt解码|`header`, `payload`|√|
|Hex/String转换|`hex to string`, `string to hex`, `十六进制转字符串`, `字符串转十六进制`|√|
## 第三方开源库 ## 第三方开源库
项目诞生离不开这些优秀的开源程序 项目诞生离不开这些优秀的开源程序
......
{ {
"name": "c-tool", "name": "c-tool",
"version": "1.6.4", "version": "1.6.5",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve --port 8081", "serve": "vue-cli-service serve --port 8081",
......
...@@ -40,6 +40,7 @@ const tool = [ ...@@ -40,6 +40,7 @@ const tool = [
{'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']}, {'name': 'jwt', 'title': 'jwt解码', 'cat': ['conversion']},
{'name': 'hexString', 'title': 'Hex/String转换', 'cat': ['conversion']},
] ]
// 工具类功能配置 // 工具类功能配置
...@@ -54,7 +55,8 @@ const utools = { ...@@ -54,7 +55,8 @@ 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'] jwt: ['jwtDecode'],
hexString: ['hex to string', 'string to hex', '十六进制转字符串', '字符串转十六机制'],
}, },
cmds: { cmds: {
timestamp: [ timestamp: [
...@@ -71,14 +73,14 @@ const utools = { ...@@ -71,14 +73,14 @@ const utools = {
"type": "regex", "type": "regex",
"match": "/[a-zA-z]+://[^\\s]*/i", "match": "/[a-zA-z]+://[^\\s]*/i",
"minLength": 8, "minLength": 8,
"feature":'generate' // 适配工具内功能 "feature": 'generate' // 适配工具内功能
}, },
{ {
"type": "regex", "type": "regex",
"match": "/[a-zA-z]+://[^\\s]*/i", "match": "/[a-zA-z]+://[^\\s]*/i",
"minLength": 8, "minLength": 8,
"feature":'reader' // 适配工具内功能 "feature": 'reader' // 适配工具内功能
} }
], ],
ip: [ ip: [
......
...@@ -105,6 +105,10 @@ const routes = [ ...@@ -105,6 +105,10 @@ const routes = [
{ {
path: '/tool/jwt', path: '/tool/jwt',
component: r => require(['./views/tool/jwt.vue'], r) component: r => require(['./views/tool/jwt.vue'], r)
},
{
path: '/tool/hexString',
component: r => require(['./views/tool/hexString.vue'], r)
} }
] ]
......
<template>
<div>
<Input v-model="current.input" :rows="7" type="textarea" placeholder="内容"></Input>
<option-block>
<FormItem>
<ButtonGroup>
<Button type="primary" @click="handle('hex')">String -> Hex</Button>
<Button type="primary" @click="handle('str')">Hex -> String</Button>
</ButtonGroup>
</FormItem>
<FormItem>
<Checkbox v-model="current.isUppercase">大写字母</Checkbox>
</FormItem>
</option-block>
<Input v-model="current.output" :rows="7" type="textarea" placeholder="结果"></Input>
</div>
</template>
<script>
export default {
created() {
this.current = Object.assign(this.current, this.$getToolData("input"))
},
methods: {
handle(type) {
if (this.current.input) {
const convert = (from, to) => str => Buffer.from(str, from).toString(to)
switch (type) {
case "hex":
this.current.output = convert('utf8', 'hex')(this.current.input);
break;
case "str":
this.current.output = convert('hex', 'utf8')(this.current.input);
break;
default:
return;
}
if (this.current.isUppercase && type === "hex") {
this.current.output = this.current.output.toUpperCase()
}
this.current.operation = type;
this.$clipboardCopy(this.current.output);
this.$saveToolData(this.current);
}
}
},
data() {
return {
current: {
input: "",
isUppercase: false,
output: "",
operation: ""
}
}
},
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册