Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
45ef7bbe
Commit
45ef7bbe
authored
Apr 30, 2021
by
fanxun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
md5加盐加密改造
parent
55839aaa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
common/utils/encryption.py
+13
-3
config.py
+9
-1
No files found.
common/utils/encryption.py
View file @
45ef7bbe
import
hashlib
from
Crypto.Cipher
import
AES
from
Crypto.Util.Padding
import
pad
#
from Crypto.Cipher import AES
#
from Crypto.Util.Padding import pad
from
base64
import
encodebytes
# 加密类
class
Encryption
:
def
get_md5
(
self
,
pwd
):
def
get_md5
(
self
,
pwd
,
salt
=
None
):
"""md5加密成32位小写"""
md5
=
hashlib
.
md5
()
if
salt
:
pwd
=
pwd
+
salt
else
:
pwd
=
pwd
if
pwd
:
md5
.
update
(
pwd
.
encode
(
'utf-8'
))
print
(
md5
.
hexdigest
()
.
lower
())
return
md5
.
hexdigest
()
.
lower
()
else
:
return
''
...
...
@@ -25,3 +30,7 @@ class Encryption:
encrypted_text_str
=
encrypted_text
.
replace
(
"
\n
"
,
""
)
# 此处我的输出结果老有换行符,所以用了临时方法将它剔除
return
encrypted_text_str
if
__name__
==
'__main__'
:
Encryption
()
.
get_md5
(
'fx123456'
,
'hikcreate_xj'
)
\ No newline at end of file
config.py
View file @
45ef7bbe
...
...
@@ -2,6 +2,13 @@ class BaseConfig():
"""基础配置类"""
# 请求头
headers
=
{
'Content-Type'
:
'application/json; charset=utf-8'
}
# 钉钉群webhook
class
DingTalk
(
BaseConfig
):
"""钉钉机器人"""
webhook
=
''
class
SSOLoginConfig
(
BaseConfig
):
"""登录配置"""
salt
=
'hikcreate_xj'
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment