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
d764b9af
Commit
d764b9af
authored
May 07, 2021
by
dengmaosheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
e01e7b92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
+37
-2
common/utils/encryption.py
+37
-2
No files found.
common/utils/encryption.py
View file @
d764b9af
...
...
@@ -2,6 +2,11 @@ import hashlib
from
Crypto.Cipher
import
AES
from
Crypto.Util.Padding
import
pad
from
base64
import
encodebytes
import
time
import
json
import
requests
# 加密类
...
...
@@ -31,6 +36,37 @@ class Encryption:
# 此处我的输出结果老有换行符,所以用了临时方法将它剔除
return
encrypted_text_str
def
aes_token
(
self
,
token
):
key
=
"HIKEDL@#"
m5dkey
=
Encryption
()
.
get_md5
(
key
)
token_plus_timestamp
=
token
+
str
(
int
(
round
(
time
.
time
()
*
1000
)))
encrypted_token
=
Encryption
()
.
aes_cipher
(
m5dkey
,
token_plus_timestamp
)
return
encrypted_token
def
get_token
(
self
,
indata
):
url
=
"http://testbmcapp.hikcreate.com/v1/user/login/gesture"
header
=
{
"Content-Type"
:
"application/json; charset=utf-8"
,
"device-type"
:
"Android"
,
"device-name"
:
"vivo+X20"
,
"device-model"
:
"vivo vivo X20"
,
"city-code"
:
"520100"
,
"Version"
:
"2.2.0"
,
"Device-Code"
:
"000000001e167ed7000000001e167ed7"
}
res
=
requests
.
post
(
url
,
json
=
indata
,
headers
=
header
)
print
(
res
.
json
())
encrypted_token
=
Encryption
()
.
aes_token
(
res
.
json
()[
"data"
][
"token"
])
print
(
encrypted_token
)
# 获取专网token
header1
=
header
.
copy
()
header1
[
"Token"
]
=
encrypted_token
resp
=
requests
.
get
(
"http://testbmcapp.hikcreate.com/token"
,
headers
=
header1
)
print
(
resp
.
json
())
pvt_token
=
resp
.
json
()[
"data"
][
"token"
]
print
(
pvt_token
)
return
encrypted_token
,
pvt_token
if
__name__
==
'__main__'
:
Encryption
()
.
get_md5
(
'fx123456'
,
'hikcreate_xj'
)
\ No newline at end of file
Encryption
()
.
get_md5
(
'fx123456'
,
'hikcreate_xj'
)
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