Commit 041d0c6c8b8adfd619c9f830f4a22cd3a02a5eb5
1 parent
5d15ed17
gx
Showing
4 changed files
with
28 additions
and
4 deletions
commons/MySession.py
... | ... | @@ -44,7 +44,7 @@ class mysession(): |
44 | 44 | self.webHeaders, self.clientHeaders, self.userInfo = cliSession().loginUser() |
45 | 45 | |
46 | 46 | def get_session(self, account, **kwargs): |
47 | - print("get_session") | |
47 | + # print("get_session") | |
48 | 48 | "如下代码,可以通过配置文件来控制登录的账户session" |
49 | 49 | self.body = self.body.replace("sg_wenze", |
50 | 50 | com.get_global_config("global_data", "account", account).split("&")[0]) |
... | ... | @@ -55,7 +55,7 @@ class mysession(): |
55 | 55 | # 使用session对象的方法POST/GET等 |
56 | 56 | re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies, **kwargs) |
57 | 57 | # 返回session对象,供其他接口使用 |
58 | - print(self.se.cookies) | |
58 | + # print(self.se.cookies) | |
59 | 59 | return self.se |
60 | 60 | |
61 | 61 | def close_session(self): | ... | ... |
commons/clientSession.py
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 | import requests |
13 | 13 | import json |
14 | 14 | from commons.scripts.readConf import readConfig |
15 | +from commons.scripts.pwdCry import pwdCry | |
15 | 16 | |
16 | 17 | class cliSession(object): |
17 | 18 | def __init__(self): |
... | ... | @@ -20,7 +21,7 @@ class cliSession(object): |
20 | 21 | def __init__(self): |
21 | 22 | rC = readConfig() |
22 | 23 | self.userName = rC.returnOptionsItems("loginInfo","userName") |
23 | - self.password = rC.returnOptionsItems("loginInfo","password") | |
24 | + self.password = pwdCry(rC.returnOptionsItems("loginInfo","password")) | |
24 | 25 | self.loginUrl = rC.returnOptionsItems("host","uapHost")+"/api/authenticationApi/loginWeb" |
25 | 26 | self.loginData = {"userName":self.userName,"password":self.password} |
26 | 27 | self.webHeaders = {"X-Requested-With":"XMLHttpRequest", | ... | ... |
commons/scripts/pwdCry.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | |
2 | + | |
3 | +# @Time : 2021/7/20 10:36 | |
4 | +# @Author : Ljq | |
5 | +# @File : pwdCry.py | |
6 | +# @Software: PyCharm | |
7 | + | |
8 | +""" | |
9 | + | |
10 | +""" | |
11 | + | |
12 | +import base64 | |
13 | +from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5 | |
14 | +from Crypto.PublicKey import RSA | |
15 | + | |
16 | +def pwdCry(string): | |
17 | + public_key = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgN7kda5L4ztOUquoHjubQIEyqBpjpaYeq+DBKXA3JNOZsMjGwLGVqfCwQg3HHAGTaWnxsp5gjmh0tSziJFgQf2u45TqA2UObOvklRhbWr56QoTNsjm72wZoSOlUzW3xHi/6PocHdy/7bMOiDf6fmYhFBZdRleX6tCAp7w6DsdbQIDAQAB' | |
18 | + key = '-----BEGIN PUBLIC KEY-----\n' + public_key + '\n-----END PUBLIC KEY-----' | |
19 | + rsakey = RSA.importKey(key) | |
20 | + cipher = Cipher_pksc1_v1_5.new(rsakey) | |
21 | + encrypt_text = cipher.encrypt(string.encode("utf-8")) | |
22 | + cipher_text = base64.b64encode(encrypt_text) | |
23 | + return cipher_text.decode() | |
0 | 24 | \ No newline at end of file | ... | ... |
config/marketConfig/test_config_hg