Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
c8dc506b
1
1024程序员开源挑战赛
项目概览
夜猫逐梦
/
1024程序员开源挑战赛
与 Fork 源项目一致
Fork自
GitCode / 1024程序员开源挑战赛(10.23-11.14)
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
1
1024程序员开源挑战赛
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8dc506b
编写于
1月 02, 2022
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加解密 TripleDES 优化
上级
26f3694e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
92 addition
and
65 deletion
+92
-65
src/views/tool/encrypt.vue
src/views/tool/encrypt.vue
+92
-65
未找到文件。
src/views/tool/encrypt.vue
浏览文件 @
c8dc506b
<
template
>
<
template
>
<
div
>
<
heightResize
ignore
:append=
"['.page-option-block']"
@
resize=
"resize"
>
<
Input
v-model=
"current.input"
:rows=
"7"
type=
"textarea"
placeholder=
"内容"
></Input
>
<
autoHeightTextarea
v-model=
"current.input"
:height=
"inputHeight"
:placeholder=
"$t('encrypt_input')"
/
>
<option-block>
<option-block
class=
"page-option-block"
>
<FormItem>
<FormItem>
<Select
v-model=
"current.type"
style=
"width:200px"
>
<Select
v-model=
"current.type"
style=
"width:200px"
>
<Option
v-for=
"v in type"
:value=
"v"
:key=
"v"
>
{{
v
}}
</Option>
<Option
v-for=
"v in type"
:value=
"v"
:key=
"v"
>
{{
v
}}
</Option>
</Select>
</Select>
</FormItem>
</FormItem>
<FormItem>
<FormItem>
<Input
v-model=
"current.password"
placeholder=
"密码/秘钥
"
></Input>
<Input
v-model=
"current.password"
:placeholder=
"$t('encrypt_password')
"
></Input>
</FormItem>
</FormItem>
<FormItem
v-if=
"current.type === 'SM2'"
>
<FormItem
v-if=
"current.type === 'SM2'"
>
<Select
v-model=
"current.sm2CipherMode"
style=
"width:100px"
>
<Select
v-model=
"current.sm2CipherMode"
style=
"width:100px"
>
...
@@ -18,39 +18,49 @@
...
@@ -18,39 +18,49 @@
</FormItem>
</FormItem>
<FormItem>
<FormItem>
<ButtonGroup>
<ButtonGroup>
<Button
type=
"primary"
@
click=
"handle('encrypt')"
>
加密
</Button>
<Button
type=
"primary"
@
click=
"handle('encrypt')"
>
{{
$t
(
'
encrypt_encrypt
'
)
}}
</Button>
<Button
type=
"primary"
@
click=
"handle('decrypt')"
>
解密
</Button>
<Button
type=
"primary"
@
click=
"handle('decrypt')"
>
{{
$t
(
'
encrypt_decrypt
'
)
}}
</Button>
<Button
type=
"primary"
@
click=
"sm2Generate()"
v-if=
"current.type === 'SM2'"
>
生成密钥对
</Button>
<Button
type=
"primary"
@
click=
"sm2Generate()"
v-if=
"current.type === 'SM2'"
>
{{
$t
(
'
encrypt_generate_secret_key
'
)
}}
</Button>
</ButtonGroup>
</ButtonGroup>
</FormItem>
</FormItem>
</option-block>
</option-block>
<
Input
v-model=
"current.output"
:rows=
"7"
type=
"textarea"
placeholder=
"结果"
></Input
>
<
autoHeightTextarea
:value=
"current.output"
:height=
"outputHeight"
:placeholder=
"$t('encrypt_output')"
/
>
</
div
>
</
heightResize
>
</
template
>
</
template
>
<
script
>
<
script
>
import
crypto
from
"
crypto-js
"
import
crypto
from
"
crypto-js
"
export
default
{
import
heightResize
from
"
./components/heightResize
"
;
import
autoHeightTextarea
from
"
./components/autoHeightTextarea
"
;
export
default
{
components
:
{
heightResize
,
autoHeightTextarea
},
created
()
{
created
()
{
this
.
current
=
Object
.
assign
(
this
.
current
,
this
.
$getToolData
(
"
input
"
)
)
this
.
$initToolData
(
'
input
'
)
},
},
methods
:
{
methods
:
{
handle
(
v
)
{
handle
(
v
)
{
const
sm2
=
require
(
'
sm-crypto
'
).
sm2
const
sm2
=
require
(
'
sm-crypto
'
).
sm2
if
(
this
.
current
.
input
)
{
if
(
this
.
current
.
input
)
{
try
{
let
output
=
""
switch
(
this
.
current
.
type
)
{
switch
(
this
.
current
.
type
)
{
case
"
AES
"
:
case
"
AES
"
:
case
"
DES
"
:
case
"
DES
"
:
case
"
RC4
"
:
case
"
RC4
"
:
case
"
Rabbit
"
:
case
"
Rabbit
"
:
case
"
TripleD
es
"
:
case
"
TripleD
ES
"
:
if
(
v
===
"
encrypt
"
)
{
if
(
v
===
"
encrypt
"
)
{
this
.
current
.
output
=
crypto
[
this
.
current
.
type
].
encrypt
(
output
=
crypto
[
this
.
current
.
type
].
encrypt
(
this
.
current
.
input
,
this
.
current
.
input
,
this
.
current
.
password
this
.
current
.
password
).
toString
();
).
toString
();
}
}
else
{
else
{
output
=
crypto
[
this
.
current
.
type
].
decrypt
(
this
.
current
.
output
=
crypto
[
this
.
current
.
type
].
decrypt
(
this
.
current
.
input
,
this
.
current
.
input
,
this
.
current
.
password
this
.
current
.
password
).
toString
(
crypto
.
enc
.
Utf8
);
).
toString
(
crypto
.
enc
.
Utf8
);
...
@@ -58,60 +68,77 @@
...
@@ -58,60 +68,77 @@
break
;
break
;
case
"
SM2
"
:
case
"
SM2
"
:
if
(
v
===
"
encrypt
"
)
{
if
(
v
===
"
encrypt
"
)
{
this
.
current
.
output
=
sm2
.
doEncrypt
(
output
=
sm2
.
doEncrypt
(
this
.
current
.
input
,
this
.
current
.
input
,
this
.
current
.
password
,
this
.
current
.
password
,
this
.
current
.
sm2CipherMode
this
.
current
.
sm2CipherMode
);
);
}
}
else
{
else
{
output
=
sm2
.
doDecrypt
(
this
.
current
.
output
=
sm2
.
doDecrypt
(
this
.
current
.
input
,
this
.
current
.
input
,
this
.
current
.
password
,
this
.
current
.
password
,
this
.
current
.
sm2CipherMode
this
.
current
.
sm2CipherMode
);
);
}
}
break
;
break
;
default
:
}
return
;
if
(
!
output
)
{
throw
new
Error
(
"
output null
"
)
}
this
.
current
.
output
=
output
}
catch
(
e
)
{
return
this
.
$Message
.
error
(
this
.
$t
(
'
encrypt_failed
'
,
[
e
.
message
]).
toString
()
)
}
}
this
.
current
.
operation
=
v
;
this
.
current
.
operation
=
v
;
this
.
$clipboardCopy
(
this
.
current
.
output
);
this
.
$clipboardCopy
(
this
.
current
.
output
);
this
.
$saveToolData
(
this
.
current
);
this
.
$saveToolData
(
this
.
current
);
}
}
},
},
sm2Generate
()
{
sm2Generate
()
{
const
sm2
=
require
(
'
sm-crypto
'
).
sm2
const
sm2
=
require
(
'
sm-crypto
'
).
sm2
let
keypair
=
sm2
.
generateKeyPairHex
()
let
keypair
=
sm2
.
generateKeyPairHex
()
let
string
=
"
公钥:
\n
"
+
keypair
.
publicKey
+
"
\n
"
+
"
私钥:
\n
"
+
keypair
.
privateKey
+
"
\n\n
"
+
let
string
=
[
"
请及时保存秘钥对, 关闭对话框后无法恢复当前秘钥数据
"
this
.
$t
(
'
encrypt_public_key
'
),
keypair
.
publicKey
,
this
.
$t
(
'
encrypt_private_key
'
),
keypair
.
privateKey
,
''
,
this
.
$t
(
'
encrypt_secret_key_prompt
'
)
].
join
(
"
\n
"
);
this
.
$Modal
.
info
({
this
.
$Modal
.
info
({
render
:
(
h
)
=>
{
render
:
(
h
)
=>
{
return
h
(
'
Input
'
,
{
return
h
(
'
Input
'
,
{
props
:
{
props
:
{
value
:
string
,
value
:
string
,
type
:
"
textarea
"
,
type
:
"
textarea
"
,
rows
:
9
rows
:
9
}
}
})
})
},
},
okText
:
"
关闭
"
,
okText
:
this
.
$t
(
'
encrypt_close
'
)
,
width
:
600
width
:
600
})
})
},
},
resize
(
height
)
{
this
.
inputHeight
=
Math
.
min
(
160
,
Math
.
ceil
(
height
/
2
))
this
.
outputHeight
=
height
-
this
.
inputHeight
}
},
},
data
()
{
data
()
{
return
{
return
{
current
:
{
current
:
{
input
:
""
,
input
:
""
,
password
:
""
,
password
:
""
,
sm2CipherMode
:
"
C1C3C2
"
,
sm2CipherMode
:
"
C1C3C2
"
,
output
:
""
,
output
:
""
,
type
:
"
AES
"
,
type
:
"
AES
"
,
operation
:
""
operation
:
""
},
},
type
:
[
"
AES
"
,
"
DES
"
,
"
RC4
"
,
"
Rabbit
"
,
"
TripleDes
"
,
"
SM2
"
],
type
:
[
"
AES
"
,
"
DES
"
,
"
RC4
"
,
"
Rabbit
"
,
"
TripleDES
"
,
"
SM2
"
],
inputHeight
:
100
,
outputHeight
:
100
}
}
},
},
}
}
</
script
>
</
script
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录