xtn-tools-pro 1.0.1.3.1__py3-none-any.whl → 1.0.1.3.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.
@@ -25,7 +25,7 @@ class XtnDeEnAir:
25
25
  BLOCK_SIZE = AES.block_size
26
26
 
27
27
  @staticmethod
28
- def de_data(key: bytes, raw: dict) -> str:
28
+ def encrypt_dict(key: bytes, raw: dict) -> str:
29
29
  """
30
30
  加密
31
31
  """
@@ -38,15 +38,19 @@ class XtnDeEnAir:
38
38
  return result
39
39
 
40
40
  @staticmethod
41
- def en_data(key: bytes, raw: str) -> str:
41
+ def decrypt_dict(key: bytes, raw: str) -> dict:
42
42
  """
43
43
  解密
44
44
  """
45
- cipher = AES.new(key, AES.MODE_ECB)
46
- enc = base64.b64decode(raw)
47
- decrypted = cipher.decrypt(enc)
48
- result = unpad(decrypted, XtnDeEnAir.BLOCK_SIZE).decode('utf-8')
49
- return result
45
+ try:
46
+ cipher = AES.new(key, AES.MODE_ECB)
47
+ enc = base64.b64decode(raw)
48
+ decrypted = cipher.decrypt(enc)
49
+ result = unpad(decrypted, XtnDeEnAir.BLOCK_SIZE).decode('utf-8')
50
+ return json.loads(result)
51
+ except (ValueError, KeyError, json.JSONDecodeError) as e:
52
+ # raise ValueError(f"解密失败: {e}")
53
+ return {}
50
54
 
51
55
 
52
56
  class XtnDeEnPro:
@@ -83,7 +87,8 @@ class XtnDeEnPro:
83
87
  result = decrypted.decode('utf-8')
84
88
  return json.loads(result)
85
89
  except (ValueError, KeyError, json.JSONDecodeError) as e:
86
- raise ValueError(f"解密失败: {e}")
90
+ # raise ValueError(f"解密失败: {e}")
91
+ return {}
87
92
 
88
93
 
89
94
  class XtnDeEnProMax:
@@ -138,7 +143,8 @@ class XtnDeEnProMax:
138
143
  result = decrypted.decode('utf-8')
139
144
  return json.loads(result)
140
145
  except (ValueError, KeyError, json.JSONDecodeError) as e:
141
- raise ValueError(f"解密失败: {e}")
146
+ # raise ValueError(f"解密失败: {e}")
147
+ return {}
142
148
 
143
149
 
144
150
  if __name__ == '__main__':
@@ -147,15 +153,15 @@ if __name__ == '__main__':
147
153
  "task_type": "update_name",
148
154
  "task_client": "tiktok",
149
155
  }
150
- sss = XtnDeEnAir.de_data(key, data)
151
- print(sss)
152
- print(XtnDeEnAir.en_data(key, sss))
153
-
154
- key_pair = RSA.generate(2048)
155
- private_key = key_pair.export_key()
156
- public_key = key_pair.publickey().export_key()
157
- print(private_key)
158
- print(public_key)
159
- sss = XtnDeEnProMax.encrypt_dict(public_key, data)
156
+ sss = XtnDeEnAir.encrypt_dict(key, data)
160
157
  print(sss)
161
- print(XtnDeEnProMax.decrypt_dict(private_key, sss))
158
+ print(XtnDeEnAir.decrypt_dict(key, sss))
159
+
160
+ # key_pair = RSA.generate(2048)
161
+ # private_key = key_pair.export_key()
162
+ # public_key = key_pair.publickey().export_key()
163
+ # print(private_key)
164
+ # print(public_key)
165
+ # sss = XtnDeEnProMax.encrypt_dict(public_key, data)
166
+ # print(sss)
167
+ # print(XtnDeEnProMax.decrypt_dict(private_key, sss))
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # 说明:
5
+ # win 操作
6
+ # History:
7
+ # Date Author Version Modification
8
+ # --------------------------------------------------------------------------------------------------
9
+ # 2025/8/11 xiatn V00.01.000 新建
10
+ # --------------------------------------------------------------------------------------------------
11
+ import ctypes
12
+ from ctypes import wintypes
13
+
14
+ user32 = ctypes.WinDLL("user32", use_last_error=True)
15
+
16
+ # 回调类型:BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
17
+ EnumWindowsProc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
18
+
19
+ # --- 明确声明所有用到的 WinAPI 的参数/返回类型 ---
20
+ user32.EnumWindows.argtypes = [EnumWindowsProc, wintypes.LPARAM]
21
+ user32.EnumWindows.restype = wintypes.BOOL
22
+
23
+ user32.GetWindowThreadProcessId.argtypes = [wintypes.HWND, ctypes.POINTER(wintypes.DWORD)]
24
+ user32.GetWindowThreadProcessId.restype = wintypes.DWORD
25
+
26
+ user32.IsWindowVisible.argtypes = [wintypes.HWND]
27
+ user32.IsWindowVisible.restype = wintypes.BOOL
28
+
29
+ user32.GetWindowTextLengthW.argtypes = [wintypes.HWND]
30
+ user32.GetWindowTextLengthW.restype = ctypes.c_int # 长度(TCHAR 数),可能为 0
31
+
32
+ user32.GetWindowTextW.argtypes = [wintypes.HWND, wintypes.LPWSTR, ctypes.c_int]
33
+ user32.GetWindowTextW.restype = ctypes.c_int # 实际拷贝的字符数
34
+
35
+
36
+ def enum_windows(only_visible=True):
37
+ """
38
+ 遍历顶层窗口,返回 [{hwnd, pid, title}, ...]
39
+ - only_visible=True 只返回可见窗口
40
+ """
41
+ results = []
42
+
43
+ @EnumWindowsProc
44
+ def callback(hwnd, lparam):
45
+ try:
46
+ # 可选过滤
47
+ if only_visible and not user32.IsWindowVisible(hwnd):
48
+ return True # 继续枚举
49
+
50
+ # 取 PID
51
+ pid = wintypes.DWORD(0)
52
+ user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
53
+
54
+ # 取标题
55
+ length = user32.GetWindowTextLengthW(hwnd)
56
+ title = ""
57
+ if length > 0:
58
+ buf = ctypes.create_unicode_buffer(length + 1)
59
+ copied = user32.GetWindowTextW(hwnd, buf, length + 1)
60
+ if copied > 0:
61
+ title = buf.value
62
+
63
+ # 结果里再把 HWND 规范化为无符号整数,避免负数显示
64
+ results.append({
65
+ "hwnd": ctypes.c_size_t(hwnd).value,
66
+ "pid": pid.value,
67
+ "title": title
68
+ })
69
+ except Exception:
70
+ # 回调里不要把异常抛给 WinAPI,否则会出现 “Exception ignored on calling ctypes callback function”
71
+ pass
72
+ return True # 继续
73
+
74
+ user32.EnumWindows(callback, 0)
75
+ return results
76
+
77
+
78
+ if __name__ == "__main__":
79
+ pass
80
+ # 枚举win窗口获取句柄和pid
81
+ # for win in enum_windows(only_visible=True):
82
+ # print(win)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xtn-tools-pro
3
- Version: 1.0.1.3.1
3
+ Version: 1.0.1.3.3
4
4
  Summary: xtn 开发工具
5
5
  Author: xtn
6
6
  Author-email: czw011122@gmail.com
@@ -55,7 +55,7 @@ xtn_tools_pro/task_pro/go_fun_v3.py,sha256=GI1OVup-izwDflAaoy_pN6xmCXat59II7v-Mo
55
55
  xtn_tools_pro/utils/__init__.py,sha256=I1_n_NP23F2lBqlF4EOlnOdLYxM8M4pbn63UhJN1hRE,418
56
56
  xtn_tools_pro/utils/audio_video.py,sha256=3Im3tGOW6IbmqDcrE1SJUg6eGyLGEyq11Qu6TCutJJw,1115
57
57
  xtn_tools_pro/utils/crypto.py,sha256=B6NC2yVxtwrbSZnngudTFRm7YRGKKEusydVVYWwxFHs,5231
58
- xtn_tools_pro/utils/crypto_pro.py,sha256=CJqK-fJryblKsj2uQN7_Sy8gn7HPCeage53xk1DfQLc,5331
58
+ xtn_tools_pro/utils/crypto_pro.py,sha256=KkTX8ITfawzKEdRw6Oq96ubnGMJrVJag-50JMheXY9c,5608
59
59
  xtn_tools_pro/utils/file_utils.py,sha256=vsUgds8I8Z2pL9a4oCv1q0JrZsDP29qLyLyGVqj5sX8,3311
60
60
  xtn_tools_pro/utils/helpers.py,sha256=0CTMY7wfSQR_DC9-v1lkKQLpWcB1FL9V_kw_5DOcZ40,4454
61
61
  xtn_tools_pro/utils/log.py,sha256=MPT9q1keNYroaw6U9a-Gc0iT0ceUEVTI-Tz2GEiWLUc,11038
@@ -64,9 +64,10 @@ xtn_tools_pro/utils/set_data.py,sha256=UR5S8xBqc4Vk8zpbrNVsxKhwaBAenaEdC7O-N3s7h
64
64
  xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,3790
65
65
  xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
66
66
  xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
67
- xtn_tools_pro-1.0.1.3.1.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
- xtn_tools_pro-1.0.1.3.1.dist-info/METADATA,sha256=Ivrk4YS7pi60sMP7xUq0323sBBR-9Cpfn3u8MkOkML4,574
69
- xtn_tools_pro-1.0.1.3.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
70
- xtn_tools_pro-1.0.1.3.1.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
71
- xtn_tools_pro-1.0.1.3.1.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
72
- xtn_tools_pro-1.0.1.3.1.dist-info/RECORD,,
67
+ xtn_tools_pro/utils/win.py,sha256=f8E-KP2a11h6WYl6byaW64x1OoEEK1jcwY796f2p63g,2943
68
+ xtn_tools_pro-1.0.1.3.3.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
+ xtn_tools_pro-1.0.1.3.3.dist-info/METADATA,sha256=HzCSqPmpvhmR7uPcnXD6VdxL03INdVyFX3nlfxvaqj8,574
70
+ xtn_tools_pro-1.0.1.3.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
71
+ xtn_tools_pro-1.0.1.3.3.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
72
+ xtn_tools_pro-1.0.1.3.3.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
73
+ xtn_tools_pro-1.0.1.3.3.dist-info/RECORD,,