Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
7bd409b0
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,体验更适合开发者的 AI 搜索 >>
提交
7bd409b0
编写于
4月 13, 2022
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bcryp #121
上级
3703610d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
75 deletion
+101
-75
src/i18n/locales/en/bcrypt.i18n.json5
src/i18n/locales/en/bcrypt.i18n.json5
+12
-0
src/i18n/locales/zh_CN/bcrypt.i18n.json5
src/i18n/locales/zh_CN/bcrypt.i18n.json5
+12
-0
src/views/tool/bcrypt.vue
src/views/tool/bcrypt.vue
+77
-75
未找到文件。
src/i18n/locales/en/bcrypt.i18n.json5
0 → 100644
浏览文件 @
7bd409b0
{
"generate": "Generate",
"password": "String",
"hash_password": "Hash",
"rounds": "Rounds",
"generate_submit": "Generate",
"check": "check",
"check_submit": "Check",
"check_result_success": "Right",
"check_result_error": "Wrong",
"rounds_range": "Rounds range [{0} - {1}]"
}
src/i18n/locales/zh_CN/bcrypt.i18n.json5
0 → 100644
浏览文件 @
7bd409b0
{
"generate": "生成",
"password": "明文(String)",
"hash_password": "哈希(Hash)",
"rounds": "Rounds",
"generate_submit": "生成",
"check": "校验",
"check_submit": "校验",
"check_result_success": "正确",
"check_result_error": "错误",
"rounds_range": "Rounds 范围 [{0} - {1}]"
}
src/views/tool/bcrypt.vue
浏览文件 @
7bd409b0
<
template
>
<Tabs
v-model=
"current.operation"
>
<TabPane
:label=
"$t('bcrypt_generate')"
name=
"generate"
>
<div
class=
"tool-bcrypt-generate-top"
style=
"margin-bottom: 10px"
>
<input-block
bottom=
"8px"
right=
"8px"
style=
"margin-bottom: 10px"
>
<Input
v-model=
"current.generate.password"
>
<span
slot=
"prepend"
></span>
</Input>
<template
slot=
"extra"
>
{{
$t
(
'
bcrypt_password
'
)
}}
</
template
>
</input-block>
<input-block
bottom=
"8px"
right=
"8px"
style=
"margin-bottom: 10px"
>
<Input
v-model=
"current.generate.rounds"
>
<span
slot=
"prepend"
></span>
</Input>
<
template
slot=
"extra"
>
{{
$t
(
'
bcrypt_rounds
'
)
}}
</
template
>
</input-block>
<Button
long
type=
"primary"
@
click=
"generate"
>
{{ $t('bcrypt_generate') }}
</Button>
</div>
<heightResize
:append=
"['.tool-bcrypt-generate-top']"
:reduce=
"52"
ignore
>
<autoHeightTextarea
:value=
"generateError ? generateError : current.generate.hash"
:placeholder=
"$t('bcrypt_result')"
/>
</heightResize>
<Input
size=
"large"
v-model=
"current.generate.password"
>
<span
slot=
"prepend"
>
{{
$t
(
'
bcrypt_password
'
)
}}
</span>
</Input>
<Input
size=
"large"
v-model=
"current.generate.rounds"
style=
"margin-top: 10px"
>
<span
slot=
"prepend"
>
{{
$t
(
'
bcrypt_rounds
'
)
}}
</span>
</Input>
<Button
:disabled=
"inOperation"
long
size=
"large"
type=
"primary"
@
click=
"generate"
style=
"margin: 10px 0"
>
{{
$t
(
'
bcrypt_generate_submit
'
)
}}
</Button>
<input-block
right=
"8px"
top=
"8px"
>
<Input
size=
"large"
:value=
"generateError ? generateError : current.generate.hash"
>
<span
slot=
"prepend"
>
{{
$t
(
'
bcrypt_hash_password
'
)
}}
</span>
</Input>
<template
slot=
"extra"
>
<Icon
style=
"cursor:pointer"
size=
"24"
v-if=
"!generateError"
type=
"md-copy"
@
click=
"$copy(current.generate.hash)"
/>
</
template
>
</input-block>
</TabPane>
<TabPane
:label=
"$t('bcrypt_check')"
name=
"check"
>
<div
class=
"tool-bcrypt-check-top"
>
<input-block
bottom=
"8px"
right=
"8px"
style=
"margin-bottom: 10px"
>
<Input
v-model=
"current.check.password"
>
<span
slot=
"prepend"
></span>
</Input>
<
template
slot=
"extra"
>
{{
$t
(
'
bcrypt_password
'
)
}}
<Input
size=
"large"
v-model=
"current.check.password"
style=
"margin-bottom: 10px"
>
<span
slot=
"prepend"
>
{{ $t('bcrypt_password') }}
</span>
</Input>
<Input
size=
"large"
v-model=
"current.check.hash"
>
<span
slot=
"prepend"
>
{{ $t('bcrypt_hash_password') }}
</span>
</Input>
<Button
:disabled=
"inOperation"
long
size=
"large"
type=
"primary"
@
click=
"check"
style=
"margin: 10px 0"
>
{{
$t('bcrypt_check_submit')
}}
</Button>
<div
style=
"margin-top: 20px;text-align: center"
>
<Tag
v-if=
"this.current.check.result !== ''"
:color=
"this.current.check.result === true ? 'success' : 'error'"
>
<
template
v-if=
"this.current.check.result === true"
>
{{
$t
(
'
bcrypt_check_result_success
'
)
}}
</
template
>
</input-block>
</div>
<heightResize
:append=
"['.tool-bcrypt-check-top']"
:reduce=
"52"
ignore
>
<input-block
bottom=
"8px"
right=
"8px"
>
<autoHeightTextarea
:value=
"current.check.hash"
:placeholder=
"$t('bcrypt_hash_password')"
/>
<
template
slot=
"extra"
>
<Tag
v-if=
"checkResult !== 0"
:color=
"checkResult ===1 ? 'success' : 'error'"
>
<template
v-if=
"checkResult ===1"
>
{{
$t
(
'
check_result_success
'
)
}}
</
template
>
<
template
v-if=
"checkResult ===-1"
>
{{
$t
(
'
check_result_error
'
)
}}
</
template
>
</Tag>
<
template
v-else
>
{{
$t
(
'
bcrypt_check_result_error
'
)
}}
</
template
>
</
input-block
>
</
heightResize
>
</
Tag
>
</
div
>
</TabPane>
</Tabs>
</template>
<
script
>
import
heightResize
from
"
./components/heightResize
"
;
import
bcrypt
from
"
bcryptjs
"
;
import
autoHeightTextarea
from
"
./components/autoHeightTextarea
"
;
export
default
{
components
:
{
heightResize
,
autoHeightTextarea
},
created
()
{
this
.
$initToolData
()
},
computed
:
{
checkResult
()
{
if
(
!
this
.
current
.
password
||
!
this
.
current
.
hash
)
{
return
0
;
methods
:
{
check
()
{
this
.
current
.
check
.
result
=
""
;
if
(
!
this
.
current
.
check
.
password
||
!
this
.
current
.
check
.
hash
)
{
return
;
}
return
bcrypt
.
compareSync
(
this
.
current
.
password
,
this
.
current
.
hash
)
?
1
:
-
1
this
.
inOperation
=
true
setTimeout
(()
=>
{
bcrypt
.
compare
(
this
.
current
.
check
.
password
,
this
.
current
.
check
.
hash
,
(
err
,
res
)
=>
{
this
.
current
.
check
.
result
=
!!
res
this
.
inOperation
=
false
this
.
saveToolData
();
});
},
300
)
},
check
()
{
return
this
.
current
.
check
}
},
watch
:
{
check
:
{
handler
()
{
this
.
saveToolData
()
},
deep
:
true
}
},
methods
:
{
generate
()
{
if
(
this
.
current
.
generate
.
password
||
!
this
.
current
.
generate
.
rounds
)
{
this
.
generateError
=
""
;
if
(
!
this
.
current
.
generate
.
password
||
!
this
.
current
.
generate
.
rounds
)
{
return
;
}
this
.
current
.
generate
.
hash
=
bcrypt
.
hashSync
(
this
.
current
.
generate
.
password
,
this
.
current
.
generate
.
rounds
)
this
.
saveToolData
();
this
.
inOperation
=
true
setTimeout
(()
=>
{
try
{
const
rounds
=
parseInt
(
this
.
current
.
generate
.
rounds
)
if
(
rounds
<
1
||
rounds
>
30
)
{
throw
new
Error
(
this
.
$t
(
'
bcrypt_rounds_range
'
,
[
4
,
30
]).
toString
())
}
bcrypt
.
hash
(
this
.
current
.
generate
.
password
,
rounds
,
(
err
,
hash
)
=>
{
if
(
err
)
{
this
.
generateError
=
err
.
message
return
;
}
this
.
current
.
generate
.
hash
=
hash
this
.
saveToolData
();
this
.
inOperation
=
false
});
}
catch
(
e
)
{
this
.
generateError
=
e
.
message
this
.
inOperation
=
false
}
},
300
)
},
saveToolData
()
{
this
.
$saveToolData
(
this
.
current
)
...
...
@@ -103,16 +103,18 @@ export default {
current
:
{
generate
:
{
password
:
''
,
rounds
:
''
,
rounds
:
'
10
'
,
hash
:
''
,
},
check
:
{
hash
:
''
,
password
:
''
,
result
:
""
,
},
operation
:
'
generate
'
,
},
generateError
:
""
inOperation
:
false
,
generateError
:
""
,
}
},
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录