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
e445fbdf
Commit
e445fbdf
authored
Apr 30, 2021
by
fanxun
Browse files
Options
Browse Files
Download
Plain Diff
保存
parents
268e348e
d4fe53ad
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
common/__init__.py
+9
-0
common/db.py
+0
-2
common/utils.py
+27
-1
No files found.
common/__init__.py
View file @
e445fbdf
from
common
import
db
common/db.py
View file @
e445fbdf
...
...
@@ -17,8 +17,6 @@ class RedisString(RedisBase):
return
result
if
__name__
==
'__main__'
:
# r= RedisString(6).get('bmc:captcha:bf46c0c0-11b4-4b7d-99d7-530f77f8ab88')
# r = RedisString(0).get('edl:sms_value:17822000010:MOBILE_REGISTER')
...
...
common/utils.py
View file @
e445fbdf
import
requests
import
requests
,
hashlib
import
json
from
config
import
BaseConfig
from
Crypto.Cipher
import
AES
from
Crypto.Util.Padding
import
pad
from
base64
import
encodebytes
def
dingTalk
(
webhook
,
message
):
"""发送消息到钉钉群"""
...
...
@@ -9,3 +12,26 @@ def dingTalk(webhook, message):
post_data
=
json
.
dumps
(
data
)
response
=
requests
.
post
(
webhook
,
headers
=
BaseConfig
.
headers
,
data
=
post_data
)
return
response
.
text
# 加密类
class
Encryption
:
def
get_md5
(
self
,
pwd
):
"""md5加密成32位小写"""
md5
=
hashlib
.
md5
()
if
pwd
:
md5
.
update
(
pwd
.
encode
(
'utf-8'
))
return
md5
.
hexdigest
()
.
lower
()
else
:
return
''
def
aes_cipher
(
self
,
key
,
aes_str
):
"""AES采用ECB模式,使用PKCS7补偿"""
aes
=
AES
.
new
(
key
.
encode
(
'utf-8'
),
AES
.
MODE_ECB
)
pad_pkcs7
=
pad
(
aes_str
.
encode
(
'utf-8'
),
AES
.
block_size
,
style
=
'pkcs7'
)
# 选择pkcs7补全
encrypt_aes
=
aes
.
encrypt
(
pad_pkcs7
)
# 加密结果
encrypted_text
=
str
(
encodebytes
(
encrypt_aes
),
encoding
=
'utf-8'
)
# 解码
encrypted_text_str
=
encrypted_text
.
replace
(
"
\n
"
,
""
)
# 此处我的输出结果老有换行符,所以用了临时方法将它剔除
return
encrypted_text_str
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