gomyck-tools 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ctools/api_result.py +0 -2
- ctools/bottle_web_base.py +1 -1
- ctools/bottle_webserver.py +4 -0
- ctools/cjson.py +5 -5
- ctools/database.py +9 -2
- ctools/date_utils.py +1 -1
- ctools/dict_wrapper.py +3 -1
- ctools/rsa.py +70 -0
- ctools/sm_tools.py +17 -4
- ctools/string_tools.py +9 -12
- ctools/sys_info.py +25 -11
- {gomyck_tools-1.2.1.dist-info → gomyck_tools-1.2.3.dist-info}/METADATA +1 -1
- {gomyck_tools-1.2.1.dist-info → gomyck_tools-1.2.3.dist-info}/RECORD +16 -16
- ctools/license.py +0 -37
- /ctools/{strDiff.py → str_diff.py} +0 -0
- {gomyck_tools-1.2.1.dist-info → gomyck_tools-1.2.3.dist-info}/WHEEL +0 -0
- {gomyck_tools-1.2.1.dist-info → gomyck_tools-1.2.3.dist-info}/top_level.txt +0 -0
ctools/api_result.py
CHANGED
ctools/bottle_web_base.py
CHANGED
@@ -112,7 +112,7 @@ def params_resolve(func):
|
|
112
112
|
elif request.method == 'POST':
|
113
113
|
content_type = request.get_header('content-type')
|
114
114
|
if content_type == 'application/json':
|
115
|
-
params = request.json
|
115
|
+
params = request.json or {}
|
116
116
|
return func(params=DictWrapper(params), *args, **kwargs)
|
117
117
|
elif content_type and 'multipart/form-data' in content_type:
|
118
118
|
form_data = request.forms.decode()
|
ctools/bottle_webserver.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
import sys
|
1
2
|
from socketserver import ThreadingMixIn
|
2
3
|
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, make_server
|
3
4
|
|
4
5
|
from bottle import ServerAdapter, Bottle, template, static_file
|
5
6
|
|
7
|
+
from ctools import sys_info
|
8
|
+
|
6
9
|
"""
|
7
10
|
app = bottle_web_base.init_app('子模块写 context_path, 主模块就不用写任何东西')
|
8
11
|
|
@@ -43,6 +46,7 @@ class CBottle:
|
|
43
46
|
|
44
47
|
def run(self):
|
45
48
|
http_server = WSGIRefServer(port=self.port)
|
49
|
+
print('Click the link below to open the service homepage %s' % '\n \t\t http://localhost:%s \n \t\t http://%s:%s' % (self.port, sys_info.get_local_ipv4(), self.port), file=sys.stderr)
|
46
50
|
self.bottle.run(server=http_server, quiet=self.quiet)
|
47
51
|
|
48
52
|
def set_index(self, path, **kwargs):
|
ctools/cjson.py
CHANGED
@@ -6,7 +6,7 @@ jsonpickle.set_preferred_backend('json')
|
|
6
6
|
jsonpickle.set_encoder_options('json', ensure_ascii=False)
|
7
7
|
jsonpickle.set_decoder_options('json')
|
8
8
|
|
9
|
-
def dumps(obj) -> str:
|
9
|
+
def dumps(obj, **kwargs) -> str:
|
10
10
|
"""
|
11
11
|
将对象转换为json字符串
|
12
12
|
:param obj: 对象
|
@@ -14,18 +14,18 @@ def dumps(obj) -> str:
|
|
14
14
|
"""
|
15
15
|
if obj is None: return None
|
16
16
|
if type(obj) == str: return obj
|
17
|
-
return f'{jsonpickle.encode(obj, unpicklable=False)}'
|
17
|
+
return f'{jsonpickle.encode(obj, unpicklable=False, make_refs=False, **kwargs)}'
|
18
18
|
|
19
|
-
def loads(json_str: str) -> dict:
|
19
|
+
def loads(json_str: str, **kwargs) -> dict:
|
20
20
|
"""
|
21
21
|
将json字符串转换为对象
|
22
22
|
:param json_str: json 字符串
|
23
23
|
:return: 对象
|
24
24
|
"""
|
25
|
-
return jsonpickle.decode(json_str)
|
25
|
+
return jsonpickle.decode(json_str, **kwargs)
|
26
26
|
|
27
27
|
def unify_to_str(json_str: str) -> str:
|
28
|
-
if not str_value_keys: return json_str
|
28
|
+
if not str_value_keys and len(str_value_keys) == 0: return json_str
|
29
29
|
obj = loads(json_str)
|
30
30
|
if isinstance(obj, list):
|
31
31
|
_handle_list(obj)
|
ctools/database.py
CHANGED
@@ -31,7 +31,13 @@ def _init():
|
|
31
31
|
Base = declarative_base()
|
32
32
|
|
33
33
|
# 密码里的@ 要替换成 %40
|
34
|
-
|
34
|
+
|
35
|
+
# sqlite connect_args={"check_same_thread": False} db_url=sqlite:///{}.format(db_url)
|
36
|
+
# sqlite 数据库, 初始化之后, 优化一下配置
|
37
|
+
# $ sqlite3 app.db
|
38
|
+
# > PRAGMA journal_mode=WAL; 设置事务的模式, wal 允许读写并发, 但是会额外创建俩文件
|
39
|
+
# > PRAGMA synchronous=NORMAL; 设置写盘策略, 默认是 FULL, 日志,数据都落, 设置成 NORMAL, 日志写完就算事务完成
|
40
|
+
|
35
41
|
def init_db(db_url: str, db_key: str='default', connect_args: dict={}, default_schema: str=None, pool_size: int=5, max_overflow: int=25, echo: bool=False):
|
36
42
|
if db_url.startswith('mysql'):
|
37
43
|
import pymysql
|
@@ -63,7 +69,8 @@ def _create_connection(db_url: str, pool_size: int=5, max_overflow: int=25, conn
|
|
63
69
|
def generate_custom_id():
|
64
70
|
return str(string_tools.get_snowflake_id())
|
65
71
|
|
66
|
-
class BaseMixin:
|
72
|
+
class BaseMixin(Base):
|
73
|
+
__abstract__ = True
|
67
74
|
obj_id = Column(Integer, primary_key=True, default=generate_custom_id)
|
68
75
|
# ext1 = Column(String)
|
69
76
|
# ext2 = Column(String)
|
ctools/date_utils.py
CHANGED
@@ -30,7 +30,7 @@ def get_file_time():
|
|
30
30
|
获取 %Y-%m-%d %H:%M:%S 文件格式时间
|
31
31
|
:return:
|
32
32
|
"""
|
33
|
-
return time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))
|
33
|
+
return time.strftime('%Y-%m-%d_%H-%M-%S-%s', time.localtime(time.time()))
|
34
34
|
|
35
35
|
def get_timestamp(offset=0):
|
36
36
|
return int(time.time() + offset)
|
ctools/dict_wrapper.py
CHANGED
@@ -6,7 +6,9 @@ __date__ = '2024/10/25 09:42'
|
|
6
6
|
class DictWrapper(dict):
|
7
7
|
def __getattr__(self, key):
|
8
8
|
res = self.get(key)
|
9
|
-
if
|
9
|
+
if res is None:
|
10
|
+
raise AttributeError(f"'{key}' not found in this Entity")
|
11
|
+
if isinstance(res, dict):
|
10
12
|
return DictWrapper(res)
|
11
13
|
return res
|
12
14
|
|
ctools/rsa.py
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
import base64
|
2
|
+
|
3
|
+
from Crypto.Cipher import PKCS1_OAEP
|
4
|
+
from Crypto.PublicKey import RSA
|
5
|
+
from Crypto.Signature import pkcs1_15
|
6
|
+
from Crypto.Hash import SHA256
|
7
|
+
|
8
|
+
from ctools import work_path, cjson
|
9
|
+
|
10
|
+
ENCRYPT_CHUNK_SIZE = 245
|
11
|
+
decrypt_CHUNK_SIZE = 512
|
12
|
+
|
13
|
+
def generate_rsa_keypair(bits=2048):
|
14
|
+
key = RSA.generate(bits)
|
15
|
+
private_key = key.export_key() # 导出私钥
|
16
|
+
public_key = key.publickey().export_key() # 导出公钥
|
17
|
+
with open("private_key.pem", "wb") as f:
|
18
|
+
f.write(private_key)
|
19
|
+
with open("public_key.pem", "wb") as f:
|
20
|
+
f.write(public_key)
|
21
|
+
|
22
|
+
def loadLicenseInfo(auth_code):
|
23
|
+
with open(work_path.get_app_path() + '/keys/license.key', 'r') as pri:
|
24
|
+
decrypt_message = decrypt(auth_code.strip(), pri.read())
|
25
|
+
return cjson.loads(decrypt_message)
|
26
|
+
|
27
|
+
# 加密函数
|
28
|
+
def encrypt(msg, public_key):
|
29
|
+
parts = b''
|
30
|
+
public_key = RSA.import_key(public_key)
|
31
|
+
cipher = PKCS1_OAEP.new(public_key)
|
32
|
+
for i in range(0, len(msg), ENCRYPT_CHUNK_SIZE):
|
33
|
+
parts += cipher.encrypt(msg[i:i + ENCRYPT_CHUNK_SIZE].encode())
|
34
|
+
encrypted_base64 = base64.b64encode(parts)
|
35
|
+
return encrypted_base64.decode()
|
36
|
+
|
37
|
+
# 解密函数
|
38
|
+
def decrypt(msg, private_key):
|
39
|
+
parts = b''
|
40
|
+
public_key = RSA.import_key(private_key)
|
41
|
+
cipher = PKCS1_OAEP.new(public_key)
|
42
|
+
encrypted_bytes = base64.b64decode(msg)
|
43
|
+
for i in range(0, len(encrypted_bytes), decrypt_CHUNK_SIZE):
|
44
|
+
parts += cipher.decrypt(encrypted_bytes[i:i + decrypt_CHUNK_SIZE])
|
45
|
+
return parts.decode()
|
46
|
+
|
47
|
+
# 验签
|
48
|
+
def verify_sign(msg, public_key, sign):
|
49
|
+
public_key = RSA.import_key(public_key)
|
50
|
+
hash_message = SHA256.new(msg.encode())
|
51
|
+
try:
|
52
|
+
pkcs1_15.new(public_key).verify(hash_message, base64.b64decode(sign.encode()))
|
53
|
+
return True
|
54
|
+
except Exception as e:
|
55
|
+
print('签名验证失败: {}'.format(e))
|
56
|
+
return False
|
57
|
+
|
58
|
+
# 签名
|
59
|
+
def sign_msg(msg, private_key):
|
60
|
+
private_key = RSA.import_key(private_key)
|
61
|
+
hash_message = SHA256.new(msg.encode())
|
62
|
+
signature = pkcs1_15.new(private_key).sign(hash_message)
|
63
|
+
return base64.b64encode(signature).decode()
|
64
|
+
|
65
|
+
|
66
|
+
# with open(work_path.get_current_path() + '/private_key.pem', 'r') as key:
|
67
|
+
# key = key.read()
|
68
|
+
# sign = sign_msg(key, key)
|
69
|
+
# with open(work_path.get_current_path() + '/public_key.pem', 'r') as pub:
|
70
|
+
# print(verify_sign(key, pub.read(), sign+'123'))
|
ctools/sm_tools.py
CHANGED
@@ -3,22 +3,35 @@ import base64
|
|
3
3
|
from gmssl import sm2, func
|
4
4
|
from gmssl.sm4 import CryptSM4, SM4_ENCRYPT, SM4_DECRYPT
|
5
5
|
|
6
|
-
sm2_crypt: sm2.CryptSM2
|
6
|
+
sm2_crypt: sm2.CryptSM2 = None
|
7
7
|
|
8
|
+
def init(private_key: str, public_key: str):
|
9
|
+
global sm2_crypt
|
10
|
+
if sm2_crypt is not None:
|
11
|
+
print('sm2 is already init!!!')
|
12
|
+
return
|
13
|
+
sm2_crypt = sm2.CryptSM2(private_key=private_key, public_key=public_key, asn1=True, mode=1)
|
8
14
|
|
9
15
|
def sign_with_sm2(sign_data: str) -> str:
|
10
|
-
|
16
|
+
if sm2_crypt is None: raise Exception('sm2 is not init!!!')
|
17
|
+
return sm2_crypt.sign_with_sm3(sign_data.encode('UTF-8'))
|
11
18
|
|
12
19
|
|
13
20
|
def verify_with_sm2(sign_val: str, sign_data: str) -> bool:
|
14
|
-
|
15
|
-
|
21
|
+
if sm2_crypt is None: raise Exception('sm2 is not init!!!')
|
22
|
+
try:
|
23
|
+
return sm2_crypt.verify_with_sm3(sign_val, sign_data.encode('UTF-8'))
|
24
|
+
except Exception as e:
|
25
|
+
print('签名验证失败: {}'.format(e))
|
26
|
+
return False
|
16
27
|
|
17
28
|
def encrypt_with_sm2(encrypt_data: str) -> str:
|
29
|
+
if sm2_crypt is None: raise Exception('sm2 is not init!!!')
|
18
30
|
return base64.b64encode(sm2_crypt.encrypt(encrypt_data.encode('UTF-8'))).decode('UTF-8')
|
19
31
|
|
20
32
|
|
21
33
|
def decrypt_with_sm2(encrypt_data: str) -> str:
|
34
|
+
if sm2_crypt is None: raise Exception('sm2 is not init!!!')
|
22
35
|
return sm2_crypt.decrypt(base64.b64decode(encrypt_data.encode('UTF-8'))).decode('UTF-8')
|
23
36
|
|
24
37
|
|
ctools/string_tools.py
CHANGED
@@ -1,24 +1,20 @@
|
|
1
|
-
import hashlib
|
2
|
-
import random
|
3
|
-
import uuid
|
4
|
-
from typing import Union
|
5
|
-
|
6
|
-
import chardet
|
7
|
-
|
8
1
|
from ctools.snow_id import SnowId
|
9
2
|
|
10
3
|
idWorker = SnowId(1, 2, 0)
|
11
4
|
|
12
|
-
def get_random_str(size: int = 10):
|
13
|
-
|
5
|
+
def get_random_str(size: int = 10) -> str:
|
6
|
+
import random
|
7
|
+
return "".join(random.sample('abcdefghjklmnpqrstuvwxyz123456789', size))
|
14
8
|
|
15
|
-
def get_uuid():
|
9
|
+
def get_uuid() -> str:
|
10
|
+
import uuid
|
16
11
|
return str(uuid.uuid1()).replace("-", "")
|
17
12
|
|
18
13
|
def get_snowflake_id():
|
19
14
|
return idWorker.get_id()
|
20
15
|
|
21
|
-
def decode_bytes(bytes_str
|
16
|
+
def decode_bytes(bytes_str):
|
17
|
+
import chardet
|
22
18
|
res_str = ""
|
23
19
|
if bytes_str:
|
24
20
|
detect = chardet.detect(bytes_str)
|
@@ -41,6 +37,7 @@ def decode_bytes(bytes_str: Union[bytes, bytearray]):
|
|
41
37
|
|
42
38
|
|
43
39
|
def check_sum(content: str):
|
40
|
+
import hashlib
|
44
41
|
try:
|
45
42
|
algorithm = hashlib.sha256()
|
46
43
|
algorithm.update(content.encode())
|
@@ -78,7 +75,7 @@ def dict_to_params(obj: dict):
|
|
78
75
|
if k == 'varname':
|
79
76
|
continue
|
80
77
|
v = str(v)
|
81
|
-
if not is_list(v) and not is_digit(v) and not is_bool(v)
|
78
|
+
if not is_list(v) and not is_digit(v) and not is_bool(v):
|
82
79
|
if k == "path" and v[:4] != "http":
|
83
80
|
v = "r'%s'" % v
|
84
81
|
else:
|
ctools/sys_info.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
-
import getpass
|
2
1
|
import hashlib
|
3
2
|
import os
|
4
3
|
import platform
|
5
|
-
import socket
|
6
|
-
import uuid
|
7
|
-
from bottle import request
|
8
4
|
|
9
5
|
from ctools import cjson, sm_tools, work_path
|
10
6
|
|
11
7
|
MACHINE_KEY = b'EnrGffoorbFyTYoS0902YyT1Fhehj4InpbezIDUuPOg='
|
12
8
|
|
13
|
-
|
14
9
|
class MachineInfo:
|
15
10
|
machine_code = None
|
16
11
|
|
17
12
|
def get_user():
|
13
|
+
import getpass
|
18
14
|
return getpass.getuser()
|
19
15
|
|
20
16
|
def get_machine_code():
|
@@ -72,27 +68,46 @@ def get_origin_machine_code():
|
|
72
68
|
|
73
69
|
|
74
70
|
def get_hash_machine_code(origin_code):
|
71
|
+
import uuid
|
75
72
|
code = origin_code + uuid.uuid1().hex
|
76
73
|
machine_code = hashlib.md5(code.encode()).hexdigest()
|
77
74
|
return machine_code.upper()
|
78
75
|
|
76
|
+
def get_public_ip():
|
77
|
+
import requests
|
78
|
+
try:
|
79
|
+
response = requests.get("https://api.ipify.org?format=json")
|
80
|
+
ip = response.json()["ip"]
|
81
|
+
return ip
|
82
|
+
except Exception as e:
|
83
|
+
return f"Failed to get public IP: {e}"
|
79
84
|
|
80
85
|
def get_local_ipv4():
|
81
|
-
|
86
|
+
import psutil
|
87
|
+
import socket
|
88
|
+
interfaces = psutil.net_if_addrs()
|
89
|
+
for interface, addresses in interfaces.items():
|
90
|
+
for address in addresses:
|
91
|
+
if address.family == socket.AF_INET and not address.address.startswith("127."):
|
92
|
+
return address.address
|
93
|
+
print("Failed to get local IPv4 address, try another way...")
|
94
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
82
95
|
try:
|
83
|
-
|
96
|
+
s.connect(("8.8.8.8", 80))
|
97
|
+
ip = s.getsockname()[0]
|
84
98
|
except Exception:
|
85
|
-
|
99
|
+
ip = '127.0.0.1'
|
100
|
+
finally:
|
101
|
+
s.close()
|
86
102
|
return ip
|
87
103
|
|
88
|
-
|
89
104
|
def get_remote_ipv4():
|
105
|
+
from bottle import request
|
90
106
|
try:
|
91
107
|
return request.remote_route[0]
|
92
108
|
except:
|
93
109
|
return '127.0.0.1'
|
94
110
|
|
95
|
-
|
96
111
|
def get_proc_pid_by(cmdline):
|
97
112
|
import psutil
|
98
113
|
"""
|
@@ -111,7 +126,6 @@ def get_proc_pid_by(cmdline):
|
|
111
126
|
pass
|
112
127
|
return pid_list
|
113
128
|
|
114
|
-
|
115
129
|
def get_os_architecture():
|
116
130
|
if '64' in platform.machine():
|
117
131
|
return '64'
|
@@ -1,22 +1,22 @@
|
|
1
1
|
ctools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
ctools/aes_tools.py,sha256=ylUgyhlx7bNCTGrbWEZVwCObzYdJTQtwEc4ZMidL2Fo,563
|
3
|
-
ctools/api_result.py,sha256=
|
3
|
+
ctools/api_result.py,sha256=BLoJiTHFAIFRPCc4zer7NHTsRQFMY1TH-qmxSMk8iLU,1208
|
4
4
|
ctools/application.py,sha256=DcuSt2m8cDuSftx6eKfJ5gA6_F9dDlzkj0K86EG4F7s,15884
|
5
5
|
ctools/b64.py,sha256=_BdhX3p3-MaSSlU2wivN5qPxQfacR3VRBr1WC456tU0,194
|
6
6
|
ctools/bashPath.py,sha256=BCN_EhYzqvwsxYso81omMNd3SbEociwSOyb9kLvu8V4,337
|
7
|
-
ctools/bottle_web_base.py,sha256=
|
8
|
-
ctools/bottle_webserver.py,sha256=
|
7
|
+
ctools/bottle_web_base.py,sha256=pP4lgaVVZZQBMg-9QZJ145kDv4F-hdSCSfH4BDeqyWU,4904
|
8
|
+
ctools/bottle_webserver.py,sha256=hyTJrfJHAh4XXQ3zPMoF6lmdJ8FTatEpEASPfGrAa2s,2779
|
9
9
|
ctools/bottle_websocket.py,sha256=wjsjKVE_tlon0hYfnzBT0Sis6yNPe318vKgTfzWYbfQ,1903
|
10
10
|
ctools/browser_element_tools.py,sha256=IFR_tWu5on0LxhuC_4yT6EOjwCsC-juIoU8KQRDqR7E,9952
|
11
11
|
ctools/call.py,sha256=BCr8wzt5qd70okv8IZn-9-EpjywleZgvA3u1vfZ_Kt8,1581
|
12
|
-
ctools/cjson.py,sha256=
|
12
|
+
ctools/cjson.py,sha256=g5OldDeD7bmdw_4NNNPfAREGXNplQxY_l9vtTz-UBTs,1331
|
13
13
|
ctools/ckafka.py,sha256=EiiGCFkSbq8yRjQKVjc2_V114hKb8fJAVIOks_XbQ3w,5944
|
14
14
|
ctools/compile_tools.py,sha256=Nybh3vnkurIKnPnubdYzigjnzFu4GaTMKPvqFdibxmE,510
|
15
15
|
ctools/console.py,sha256=EZumuyynwteKUhUxB_XoulHswDxHd75OQB34RiZ-OBM,1807
|
16
16
|
ctools/cron_lite.py,sha256=f9g7-64GsCxcAW-HUAvT6S-kooScl8zaJyqwHY-X_rE,8308
|
17
|
-
ctools/database.py,sha256=
|
18
|
-
ctools/date_utils.py,sha256
|
19
|
-
ctools/dict_wrapper.py,sha256=
|
17
|
+
ctools/database.py,sha256=M28inDYU4X69BFeVGCOwzKFtYHuQFgEm9_aoTXmrTzY,5803
|
18
|
+
ctools/date_utils.py,sha256=qkIvn2TGQ97vUw2ppBfHE7IyCUqg0s1FzrB0BJAsaBo,868
|
19
|
+
ctools/dict_wrapper.py,sha256=6lZUyHomdn5QdjQTg7EL1sC_I6tOlh8ofMRQT3XGQjM,398
|
20
20
|
ctools/douglas_rarefy.py,sha256=43WRjGGsQ_o1yPEXypA1Xv_yuo90RVo7qaYGRslx5gQ,4890
|
21
21
|
ctools/download_tools.py,sha256=oJbG12Hojd0J17sAlvMU480P3abi4_AB9oZkEBGFPuo,1930
|
22
22
|
ctools/enums.py,sha256=QbHa3j7j4-BDdwaga5Y0nYfA2uNSVJDHumYdIZdKVkM,118
|
@@ -26,7 +26,6 @@ ctools/html_soup.py,sha256=rnr8M3gn3gQGo-wNaNFXDjdzp8AAkv9o4yqfIIfO-zw,1567
|
|
26
26
|
ctools/http_utils.py,sha256=dG26aci1_YxAyKwYqMKFw4wZAryLkDyvnQ3hURjB6Lk,768
|
27
27
|
ctools/images_tools.py,sha256=TapXYCPqC7GesgrALecxxa_ApuT_dxUG5fqQIJF2bNY,670
|
28
28
|
ctools/imgDialog.py,sha256=zFeyPmpnEn9Ih7-yuJJrePqW8Myj3jC9UYMTDk-umTs,1385
|
29
|
-
ctools/license.py,sha256=0Kh7lXL7LD1PQqyijHajFL0GbmZGNB88PA2WskbQn_s,1066
|
30
29
|
ctools/metrics.py,sha256=vq9Fnq2fhmhS4yoHS4gO7ArKS033Eou8vpA779Uue0I,4414
|
31
30
|
ctools/mqtt_utils.py,sha256=ZWSZiiNJLLlkHF95S6LmRmkYt-iIL4K73VdN3b1HaHw,10702
|
32
31
|
ctools/obj.py,sha256=GYS1B8NyjtUIh0HlK9r8avC2eGbK2SJac4C1CGnfGhI,479
|
@@ -35,13 +34,14 @@ ctools/plan_area_tools.py,sha256=pySri43bVfkHjzlKujML-Nk8B3QLxuYv5KJMha-MLmU,331
|
|
35
34
|
ctools/process_pool.py,sha256=1TuZySUbQjgYYcuwis54DIwQTimWvTLNahSra7Ia8Ps,951
|
36
35
|
ctools/pty_tools.py,sha256=KI3dOyv2JLZmU1VfD1aLMq9r9d5VCu3TdtcezZayBEI,1622
|
37
36
|
ctools/resource_bundle_tools.py,sha256=wA4fmD_ZEcrpcvUZKa60uDDX-nNQSVz1nBh0A2GVuTI,3796
|
37
|
+
ctools/rsa.py,sha256=c0q7oStlpSfTxmn900XMDjyOGS1A7tVsUIocr0nL2UI,2259
|
38
38
|
ctools/screenshot_tools.py,sha256=KoljfgqW5x9aLwKdIfz0vR6v-fX4XjE92HudkDxC2hE,4539
|
39
39
|
ctools/sign.py,sha256=JOkgpgsMbk7T3c3MOj1U6eiEndUG9XQ-uIX9e615A_Y,566
|
40
|
-
ctools/sm_tools.py,sha256=
|
40
|
+
ctools/sm_tools.py,sha256=CDfgupqs_nrZs-135ZvDu6QIx4aamJVdg7vuLs9_0yw,1678
|
41
41
|
ctools/snow_id.py,sha256=hYinnRN-aOule4_9vfgXB7XnsU-56cIS3PhzAwWBc5E,2270
|
42
|
-
ctools/
|
43
|
-
ctools/string_tools.py,sha256=
|
44
|
-
ctools/sys_info.py,sha256=
|
42
|
+
ctools/str_diff.py,sha256=QUtXOfsRLTFozH_zByqsC39JeuG3eZtrwGVeLyaHYUI,429
|
43
|
+
ctools/string_tools.py,sha256=itK59W4Ed4rQzuyHuioNgDRUcBlfb4ZoZnwmS9cJxiI,1887
|
44
|
+
ctools/sys_info.py,sha256=NvKCuBlWHHiW4bDI4tYZUo3QusvODm1HlW6aAkrllnE,4248
|
45
45
|
ctools/sys_log.py,sha256=oqb1S41LosdeZxtogFVgDk8R4sjiHhUeYJLCzHd728E,2805
|
46
46
|
ctools/thread_pool.py,sha256=qb68ULHy1K7u3MC7WP49wDhmgUhgWazd9FRuFbClET4,925
|
47
47
|
ctools/upload_tools.py,sha256=sqe6K3ZWiyY58pFE5IO5mNaS1znnS7U4c4UqY8noED4,1068
|
@@ -51,7 +51,7 @@ ctools/wordFill.py,sha256=dB1OLt6GLmWdkDV8H20VWbJmY4ggNNI8iHD1ocae2iM,875
|
|
51
51
|
ctools/word_fill.py,sha256=xeo-P4DOjQUqd-o9XL3g66wQrE2diUPGwFywm8TdVyw,18210
|
52
52
|
ctools/word_fill_entity.py,sha256=eX3G0Gy16hfGpavQSEkCIoKDdTnNgRRJrFvKliETZK8,985
|
53
53
|
ctools/work_path.py,sha256=i4MTUobqNW2WMrT3mwEC_XYQ0_IhFmKoNpTX2W6A8Tc,1680
|
54
|
-
gomyck_tools-1.2.
|
55
|
-
gomyck_tools-1.2.
|
56
|
-
gomyck_tools-1.2.
|
57
|
-
gomyck_tools-1.2.
|
54
|
+
gomyck_tools-1.2.3.dist-info/METADATA,sha256=Zc516X4DTe8baLkQjf8ivEsGohdI9UgSeWH709wl3y4,1004
|
55
|
+
gomyck_tools-1.2.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
56
|
+
gomyck_tools-1.2.3.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
|
57
|
+
gomyck_tools-1.2.3.dist-info/RECORD,,
|
ctools/license.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
import base64
|
2
|
-
|
3
|
-
from Crypto.Cipher import PKCS1_OAEP
|
4
|
-
from Crypto.PublicKey import RSA
|
5
|
-
|
6
|
-
from ctools import work_path, cjson
|
7
|
-
|
8
|
-
ENCRYPT_CHUNK_SIZE = 245
|
9
|
-
decrypt_CHUNK_SIZE = 512
|
10
|
-
|
11
|
-
|
12
|
-
# 加密函数
|
13
|
-
def encrypt(msg, public_key):
|
14
|
-
parts = b''
|
15
|
-
private_key = RSA.import_key(public_key)
|
16
|
-
cipher = PKCS1_OAEP.new(private_key)
|
17
|
-
for i in range(0, len(msg), ENCRYPT_CHUNK_SIZE):
|
18
|
-
parts += cipher.encrypt(msg[i:i + ENCRYPT_CHUNK_SIZE].encode())
|
19
|
-
encrypted_base64 = base64.b64encode(parts)
|
20
|
-
return encrypted_base64.decode()
|
21
|
-
|
22
|
-
|
23
|
-
# 解密函数
|
24
|
-
def decrypt(msg, private_key):
|
25
|
-
parts = b''
|
26
|
-
public_key = RSA.import_key(private_key)
|
27
|
-
cipher = PKCS1_OAEP.new(public_key)
|
28
|
-
encrypted_bytes = base64.b64decode(msg)
|
29
|
-
for i in range(0, len(encrypted_bytes), decrypt_CHUNK_SIZE):
|
30
|
-
parts += cipher.decrypt(encrypted_bytes[i:i + decrypt_CHUNK_SIZE])
|
31
|
-
return parts.decode()
|
32
|
-
|
33
|
-
|
34
|
-
def loadLicenseInfo(auth_code):
|
35
|
-
with open(work_path.get_app_path() + '/keys/license.key', 'r') as pri:
|
36
|
-
decrypt_message = decrypt(auth_code.strip(), pri.read())
|
37
|
-
return cjson.loads(decrypt_message)
|
File without changes
|
File without changes
|
File without changes
|