raytoolsbox 1.1.2__tar.gz → 2.0.1__tar.gz

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.
Files changed (59) hide show
  1. raytoolsbox-2.0.1/.gitignore +24 -0
  2. raytoolsbox-2.0.1/.python-version +1 -0
  3. raytoolsbox-2.0.1/C++/350/260/203/347/224/250/cpp/346/211/223/345/214/205/344/270/272dll.py +176 -0
  4. raytoolsbox-2.0.1/C++/350/260/203/347/224/250/fa.py +14 -0
  5. raytoolsbox-2.0.1/C++/350/260/203/347/224/250/mylib.cpp +6 -0
  6. raytoolsbox-2.0.1/C++/350/260/203/347/224/250/mylib.dll +0 -0
  7. raytoolsbox-2.0.1/CHANGELOG.md +77 -0
  8. raytoolsbox-2.0.1/CLAUDE.md +108 -0
  9. raytoolsbox-2.0.1/PKG-INFO +195 -0
  10. raytoolsbox-2.0.1/README.md +180 -0
  11. raytoolsbox-2.0.1/main.py +6 -0
  12. raytoolsbox-2.0.1/pyproject.toml +55 -0
  13. raytoolsbox-2.0.1/src/raytoolsbox/security/__init__.py +0 -0
  14. {raytoolsbox-1.1.2 → raytoolsbox-2.0.1}/src/raytoolsbox/security/authenticator.py +56 -33
  15. {raytoolsbox-1.1.2 → raytoolsbox-2.0.1}/src/raytoolsbox/security/crypto_manager.py +90 -133
  16. {raytoolsbox-1.1.2 → raytoolsbox-2.0.1}/src/raytoolsbox/security/pin_manager.py +24 -24
  17. raytoolsbox-2.0.1/src/raytoolsbox/utils/__init__.py +0 -0
  18. raytoolsbox-2.0.1/src/raytoolsbox/utils/mailToPhone.py +104 -0
  19. raytoolsbox-2.0.1/src/raytoolsbox/utils/monitor_func.py +300 -0
  20. raytoolsbox-2.0.1/src/raytoolsbox/utils/useful_func.py +238 -0
  21. raytoolsbox-2.0.1/tests/readme.md +1 -0
  22. raytoolsbox-2.0.1/tests/test_authenticator.py +140 -0
  23. {raytoolsbox-1.1.2 → raytoolsbox-2.0.1}/tests/test_crypto_manager.py +51 -4
  24. raytoolsbox-2.0.1/tests/test_mail_to_phone.py +54 -0
  25. raytoolsbox-2.0.1/tests/test_monitor_func.py +117 -0
  26. raytoolsbox-2.0.1/tests/test_pin_manager.py +80 -0
  27. raytoolsbox-2.0.1/tests/test_useful_func.py +204 -0
  28. raytoolsbox-2.0.1/uv.lock +1619 -0
  29. raytoolsbox-2.0.1/uv.toml +1 -0
  30. raytoolsbox-2.0.1/web/345/217/212/346/225/260/346/215/256/345/267/245/345/205/267/Flask/345/222/214FastAPI/345/257/271/346/257/224/FastAPI/351/243/216/346/240/274.py +14 -0
  31. raytoolsbox-2.0.1/web/345/217/212/346/225/260/346/215/256/345/267/245/345/205/267/Flask/345/222/214FastAPI/345/257/271/346/257/224/Flask/351/243/216/346/240/274.py +13 -0
  32. raytoolsbox-2.0.1/web/345/217/212/346/225/260/346/215/256/345/267/245/345/205/267//345/256/211/345/205/250/346/200/247//345/212/240/345/257/206/350/247/243/345/257/206/344/270/216/347/255/276/345/220/215/351/252/214/347/255/276.py +73 -0
  33. raytoolsbox-2.0.1/web/345/217/212/346/225/260/346/215/256/345/267/245/345/205/267//345/256/211/345/205/250/346/200/247//351/252/214/350/257/201/345/231/250.py +241 -0
  34. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/DPI/347/252/227/345/217/243/346/265/213/351/207/217.py +135 -0
  35. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/USB/347/275/221/347/273/234/345/205/261/344/272/253/USB/347/275/221/347/273/234/345/205/261/344/272/253.py +208 -0
  36. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/USB/347/275/221/347/273/234/345/205/261/344/272/253/resource/ICON_running.png +0 -0
  37. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/USB/347/275/221/347/273/234/345/205/261/344/272/253/resource/ICON_stopped.png +0 -0
  38. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/USB/347/275/221/347/273/234/345/205/261/344/272/253/resource/favicon (1).ico +0 -0
  39. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267/USB/347/275/221/347/273/234/345/205/261/344/272/253/usb_watcher.py +79 -0
  40. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267//350/257/255/351/237/263/350/275/254/346/226/207/345/255/227.py +104 -0
  41. raytoolsbox-2.0.1//345/256/236/347/224/250/345/267/245/345/205/267//350/275/256/350/257/242/347/216/207/346/237/245/350/257/242.py +159 -0
  42. {raytoolsbox-1.1.2/src/raytoolsbox/utils → raytoolsbox-2.0.1//351/202/256/344/273/266/345/217/221/351/200/201}/mailToPhone.py +10 -16
  43. raytoolsbox-2.0.1//351/202/256/344/273/266/345/217/221/351/200/201//351/207/215/350/246/201/346/227/245/346/234/237/346/217/220/351/206/222/date_emalil_note.py +147 -0
  44. raytoolsbox-2.0.1//351/202/256/344/273/266/345/217/221/351/200/201//351/207/215/350/246/201/346/227/245/346/234/237/346/217/220/351/206/222/html_get.py +55 -0
  45. raytoolsbox-1.1.2/PKG-INFO +0 -135
  46. raytoolsbox-1.1.2/README.md +0 -120
  47. raytoolsbox-1.1.2/pyproject.toml +0 -67
  48. raytoolsbox-1.1.2/setup.cfg +0 -4
  49. raytoolsbox-1.1.2/src/raytoolsbox/security/__init__.py +0 -10
  50. raytoolsbox-1.1.2/src/raytoolsbox/utils/__init__.py +0 -9
  51. raytoolsbox-1.1.2/src/raytoolsbox/utils/useful_func.py +0 -188
  52. raytoolsbox-1.1.2/src/raytoolsbox.egg-info/PKG-INFO +0 -135
  53. raytoolsbox-1.1.2/src/raytoolsbox.egg-info/SOURCES.txt +0 -18
  54. raytoolsbox-1.1.2/src/raytoolsbox.egg-info/dependency_links.txt +0 -1
  55. raytoolsbox-1.1.2/src/raytoolsbox.egg-info/requires.txt +0 -6
  56. raytoolsbox-1.1.2/src/raytoolsbox.egg-info/top_level.txt +0 -1
  57. raytoolsbox-1.1.2/tests/test_fuzz_crypto.py +0 -33
  58. raytoolsbox-1.1.2/tests/test_send_email.py +0 -22
  59. {raytoolsbox-1.1.2 → raytoolsbox-2.0.1}/src/raytoolsbox/__init__.py +0 -0
@@ -0,0 +1,24 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+ .hypothesis/
9
+
10
+
11
+ # Virtual environments
12
+ .venv
13
+
14
+ # 配置文件
15
+ .env
16
+ *.cfg
17
+ *.ini
18
+ *.yaml
19
+ *.yml
20
+
21
+ %数据
22
+ data/**/*.csv
23
+ tests/testData/*
24
+ *.bin
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,176 @@
1
+ from tkinterdnd2 import DND_FILES, TkinterDnD
2
+ import tkinter as tk
3
+ from tkinter import ttk, messagebox
4
+ import subprocess
5
+ import threading
6
+ import time
7
+ import os
8
+ import tkinter.filedialog as fd # ⬅️ 新增导入
9
+
10
+ def get_short_path(path):
11
+ """将路径转换为 Windows 8.3短路径,适合 cmd/g++/gcc,解决中文、特殊字符路径无法识别问题"""
12
+ import ctypes
13
+ buf = ctypes.create_unicode_buffer(260)
14
+ if ctypes.windll.kernel32.GetShortPathNameW(path, buf, 260):
15
+ return buf.value
16
+ return path
17
+
18
+ def show_error(title, message):
19
+ errwin = tk.Toplevel(root)
20
+ errwin.title(title)
21
+ errwin.geometry("520x240")
22
+ errwin.resizable(False, False)
23
+ tk.Label(errwin, text=title, font=("微软雅黑", 12, "bold")).pack(pady=8)
24
+ text = tk.Text(errwin, wrap="word", height=8, width=64)
25
+ text.insert("1.0", message)
26
+ text.config(state='normal')
27
+ text.pack(padx=8)
28
+ text.focus_set()
29
+ text.tag_add("sel", "1.0", "end")
30
+ def copy_text():
31
+ errwin.clipboard_clear()
32
+ errwin.clipboard_append(text.get("1.0", "end").strip())
33
+ # 复制反馈
34
+ btn_copy.config(text="已复制!", state="disabled")
35
+ errwin.after(1200, lambda: btn_copy.config(text="复制内容", state="normal"))
36
+ btn_frame = tk.Frame(errwin)
37
+ btn_frame.pack(pady=5)
38
+ btn_copy = tk.Button(btn_frame, text="复制内容", command=copy_text)
39
+ btn_copy.pack(side="left", padx=20)
40
+ tk.Button(btn_frame, text="关闭", command=errwin.destroy).pack(side="right", padx=20)
41
+
42
+ def show_success(dll_path):
43
+ win = tk.Toplevel(root)
44
+ win.title("编译成功")
45
+ win.geometry("580x350")
46
+ win.resizable(False, False)
47
+ tk.Label(win, text="编译成功", font=("微软雅黑", 13, "bold")).pack(pady=(12,2))
48
+
49
+ info = "以下是调用此 DLL 的示例代码,可点击复制"
50
+ tk.Label(win, text=info, font=("微软雅黑", 11)).pack(pady=(0,8))
51
+
52
+ code = f"""import ctypes
53
+ import os
54
+ # DLL 路径(注意:路径要加 r"" 或用双斜杠)
55
+ dll_path = r'{dll_path}'
56
+ # 加载 DLL
57
+ lib = ctypes.CDLL(dll_path)
58
+ # 设置参数类型和返回类型(必须!防止类型错误)
59
+ lib.函数名.argtypes = [ctypes.c_int, ctypes.c_int]
60
+ lib.函数名.restype = ctypes.c_int
61
+
62
+ """
63
+
64
+ text = tk.Text(win, wrap="word", height=9, width=72, font=("Consolas", 11))
65
+ text.insert("1.0", code)
66
+ text.config(state='normal')
67
+ text.pack(padx=8)
68
+ text.focus_set()
69
+ text.tag_add("sel", "1.0", "end")
70
+
71
+ def copy_text():
72
+ win.clipboard_clear()
73
+ win.clipboard_append(text.get("1.0", "end").strip())
74
+ # 复制反馈
75
+ btn_copy.config(text="已复制!", state="disabled")
76
+ win.after(1200, lambda: btn_copy.config(text="复制内容", state="normal"))
77
+ btn_frame = tk.Frame(win)
78
+ btn_frame.pack(pady=5)
79
+ btn_copy = tk.Button(btn_frame, text="复制内容", command=copy_text)
80
+ btn_copy.pack(side="left", padx=25)
81
+ tk.Button(btn_frame, text="关闭", command=win.destroy).pack(side="right", padx=25)
82
+
83
+ def compile_task(cpp_path, dll_path, progressbar, root):
84
+ try:
85
+ outdir = os.path.dirname(dll_path)
86
+ if not os.path.exists(outdir):
87
+ os.makedirs(outdir)
88
+ progressbar['value'] = 8
89
+ # 使用短路径放到编译命令里
90
+ cmd = f'g++ -shared -o "{dll_path}" "{cpp_path}"'
91
+ proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
92
+ # 伪进度条
93
+ for i in range(12, 90, 7):
94
+ if proc.poll() is not None:
95
+ break
96
+ progressbar['value'] = i
97
+ time.sleep(0.12)
98
+ proc.wait()
99
+ progressbar['value'] = 100
100
+ if proc.returncode == 0:
101
+ root.after(120, lambda: show_success(dll_path))
102
+ else:
103
+ err = proc.stderr.read().decode(errors='ignore')
104
+ root.after(120, lambda: show_error("编译失败", err or "未知错误"))
105
+ except Exception as e:
106
+ root.after(120, lambda: show_error("编译异常", str(e)))
107
+ finally:
108
+ root.after(800, lambda: progressbar.config(value=0))
109
+
110
+ def on_drop(event):
111
+ print("Dropped path:", event.data)
112
+ cpp_path = event.data.strip("{}").strip()
113
+ if not (cpp_path.lower().endswith('.cpp') or cpp_path.lower().endswith('.c')):
114
+ messagebox.showwarning("错误", "请拖入 .c 或 .cpp 文件!")
115
+ return
116
+ cpp_path = os.path.abspath(cpp_path)
117
+ dll_path = os.path.splitext(cpp_path)[0] + ".dll"
118
+ outdir = os.path.dirname(dll_path)
119
+ if not os.path.exists(outdir):
120
+ os.makedirs(outdir)
121
+ cpp_path_short = get_short_path(cpp_path)
122
+ dll_path_short = get_short_path(dll_path)
123
+ progressbar['value'] = 0
124
+ compile_thread = threading.Thread(
125
+ target=compile_task,
126
+ args=(cpp_path_short, dll_path_short, progressbar, root),
127
+ daemon=True
128
+ )
129
+ compile_thread.start()
130
+
131
+ def on_click(event=None):
132
+ cpp_path = fd.askopenfilename(
133
+ title="选择C/C++源文件",
134
+ filetypes=[("C/C++ 文件", "*.cpp;*.c"), ("所有文件", "*.*")]
135
+ )
136
+ if not cpp_path:
137
+ return
138
+ # 让选中文件走 on_drop 逻辑(但 event 变了)
139
+ class DummyEvent: pass
140
+ dummy = DummyEvent()
141
+ # 这里 event.data 与拖拽一致,设为选中文件路径
142
+ dummy.data = cpp_path
143
+ on_drop(dummy)
144
+
145
+
146
+ root = TkinterDnD.Tk()
147
+ root.title("C++拖拽自动编译DLL工具")
148
+ root.geometry("540x320")
149
+
150
+
151
+ # === 新增:主窗口置顶勾选框 ===
152
+ is_topmost = tk.BooleanVar(value=True) # 默认不置顶
153
+ def on_topmost():
154
+ root.attributes('-topmost', is_topmost.get())
155
+
156
+ topmost_cb = tk.Checkbutton(
157
+ root,
158
+ text='窗口置顶',
159
+ variable=is_topmost,
160
+ command=on_topmost,
161
+ font=("微软雅黑", 11)
162
+ )
163
+ topmost_cb.pack(pady=(5,10),padx=(0,5), anchor='nw' )
164
+
165
+
166
+ drop_area = tk.Label(root, text="拖入 .cpp /.c文件,\n自动编译为 DLL", relief="ridge", width=40, height=8, bg="#e0e0e0",font=("微软雅黑", 15))
167
+ drop_area.pack()
168
+
169
+ drop_area.drop_target_register(DND_FILES)
170
+ drop_area.dnd_bind('<<Drop>>', on_drop)
171
+ drop_area.bind("<Button-1>", on_click) # ⬅️ 新增:点击选择文件
172
+
173
+ progressbar = ttk.Progressbar(root, length=500, mode='determinate')
174
+ progressbar.pack(pady=(5,20))
175
+
176
+ root.mainloop()
@@ -0,0 +1,14 @@
1
+ import ctypes
2
+ import os
3
+ # DLL 路径(注意:路径要加 r"" 或用双斜杠)
4
+ dll_path = r'G:\VScode\Python_test\C++调用\mylib.dll'
5
+ # 加载 DLL
6
+ lib = ctypes.CDLL(dll_path)
7
+ # 设置参数类型和返回类型(必须!防止类型错误)
8
+ lib.函数名.argtypes = [ctypes.c_int, ctypes.c_int]
9
+ lib.函数名.restype = ctypes.c_int
10
+ # 调用 DLL 中的函数
11
+ a = 5
12
+ b = 7
13
+ result = lib.add(a, b)
14
+ print(f"add({a}, {b}) = {result}") # 输出 add(5, 7) = 12
@@ -0,0 +1,6 @@
1
+ // mylib.cpp
2
+ extern "C" {
3
+ __declspec(dllexport) int add(int a, int b) {
4
+ return a + b;
5
+ }
6
+ }
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ 所有对本项目的显著变更都将记录在此文件中。
4
+
5
+ 格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),
6
+ 版本管理遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - 子进程/子线程执行器(`run_in_subprocess` / `run_in_subthread`),支持超时与异常透传
13
+ - Ruff 代码检查集成
14
+
15
+ ### Changed
16
+
17
+ - 测试体系重构,切换至 Hatchling 构建系统
18
+ - 引入 `src/` layout 项目布局
19
+ - 移除 `python-semantic-release`,改为手动管理版本和 CHANGELOG
20
+ - 显式指定 wheel 打包目录 `src/raytoolsbox`
21
+
22
+ ### Removed
23
+
24
+ - `python-semantic-release` 自动版本管理工具及其 `[tool.semantic_release]` 配置
25
+
26
+ ## [2.0.1] - 2026-07-03
27
+
28
+ ### Added
29
+
30
+ - 集成 `python-semantic-release` 自动版本管理
31
+
32
+ ### Changed
33
+
34
+ - `uv` 全面替代 `pip`/`poetry` 管理依赖和构建
35
+
36
+ ## [1.1.2] - 2026-02-05
37
+
38
+ ### Fixed
39
+
40
+ - 修复资源路径获取逻辑,增强 PyInstaller 打包兼容性
41
+
42
+ ### Changed
43
+
44
+ - 重构函数注释体系,统一文档风格
45
+
46
+ ## [1.1.1] - 2026-02-02
47
+
48
+ ### Fixed
49
+
50
+ - 调整 Python 支持范围为 `>=3.11`
51
+
52
+ ### Changed
53
+
54
+ - Python 版本从 3.13 降级至 3.11,提升兼容性
55
+
56
+ ## [1.1.0] - 2026-02-02
57
+
58
+ ### Added
59
+
60
+ - **PinManager** — PBKDF2-HMAC-SHA256 PIN 码哈希存储模块
61
+ - **Authenticator** — TOTP 双因素认证模块
62
+
63
+ ### Changed
64
+
65
+ - 重构项目结构,将所有密码学相关操作归入 `security` 子包
66
+
67
+ ## [1.0.0] - 2026-02-01
68
+
69
+ ### Added
70
+
71
+ - 项目初始发布
72
+ - **CryptoManager** — ECC 加密套件(X25519 + ChaCha20-Poly1305 + Ed25519 签名)
73
+ - 邮件发送、性能监控、资源路径解析等工具模块
74
+
75
+ ---
76
+
77
+ 各版本标签:`v1.0.0` `v1.1.0` `v1.1.1` `v1.1.2` `2.0.1`
@@ -0,0 +1,108 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## 项目概述
6
+
7
+ RayToolsbox 是一个模块化的个人 Python 工具箱(`raytoolsbox` v2.0.1),提供常用开发工具和安全模块。Python >=3.11,MIT 协议。
8
+
9
+ ## 常用命令
10
+
11
+ ```bash
12
+ # 运行全部测试
13
+ uv run pytest
14
+
15
+ # 运行单个测试文件
16
+ uv run pytest tests/test_crypto_manager.py
17
+
18
+ # 运行单条测试
19
+ uv run pytest tests/test_crypto_manager.py::test_text_roundtrip
20
+
21
+ # 测试文件与源模块对应关系
22
+ # test_authenticator.py → security/authenticator.py
23
+ # test_crypto_manager.py → security/crypto_manager.py(含 fuzz)
24
+ # test_mail_to_phone.py → utils/mailToPhone.py
25
+ # test_monitor_func.py → utils/monitor_func.py
26
+ # test_pin_manager.py → security/pin_manager.py
27
+ # test_useful_func.py → utils/useful_func.py
28
+
29
+ # 安装依赖
30
+ uv add <package>
31
+
32
+ # 安装开发依赖
33
+ uv add --group dev <package>
34
+
35
+ # 构建分发包
36
+ uv build
37
+
38
+ # 发布到 PyPI(需 token)
39
+ uv publish
40
+
41
+ # 格式化代码
42
+ uv run ruff format .
43
+
44
+ # 代码检查
45
+ uv run ruff check .
46
+ ```
47
+
48
+ ## 发布流程
49
+
50
+ 发布前必须更新CHANGELOG.md
51
+ ```bash
52
+ # 1. 更新版本号(pyproject.toml 中的 version 字段)
53
+ # 2. 更新 CHANGELOG.md
54
+ # 将 [Unreleased] 内容移到新版本条目下,
55
+ # 格式参照 Keep a Changelog 标准
56
+ # 3. 提交并打标签
57
+ git add -A
58
+ git commit -m "release: v<version>"
59
+ git tag v<version>
60
+ # 4. 构建
61
+ uv build
62
+ # 5. 发布到 PyPI
63
+ uv publish
64
+ ```
65
+
66
+ ### 版本号规则
67
+
68
+ 遵循 SemVer:
69
+ - **主版本**:不兼容的 API 变更
70
+ - **次版本**:向下兼容的新功能
71
+ - **修订号**:向下兼容的问题修复
72
+
73
+ ### CHANGELOG 约定
74
+
75
+ - `[Unreleased]` 始终在顶部,积累下一次发布的变更
76
+ - 发布时将 `[Unreleased]` 内容移到新版本条目,标注日期
77
+ - 章节使用英文标题:`Added` `Changed` `Deprecated` `Removed` `Fixed` `Security`
78
+ - 描述使用中文以便阅读
79
+
80
+ ## 项目架构
81
+
82
+ ```
83
+ src/raytoolsbox/
84
+ ├── utils/ # 通用工具模块
85
+ │ ├── useful_func.py # 资源路径、窗口居中、GitHub 仓库查询
86
+ │ ├── mailToPhone.py # SMTP 邮件发送(支持 QQ/Gmail 等多服务商)
87
+ │ └── monitor_func.py # 性能计时器、内存监控、benchmark 测试(to_test_func)
88
+ └── security/ # 安全模块
89
+ ├── crypto_manager.py # CryptoManager — ECC 加密套件:X25519 + ChaCha20-Poly1305 + Ed25519 签名
90
+ ├── authenticator.py # Authenticator — TOTP 双因素认证(RFC 6238)
91
+ └── pin_manager.py # PinManager — PIN 码 PBKDF2 哈希存储
92
+ ```
93
+
94
+ ### 模块职责
95
+
96
+ - **`CryptoManager`** — 非对称加密/解密、数字签名/验签。X25519 ECDH 密钥交换 + ChaCha20-Poly1305 AEAD 对称加密 + HKDF 密钥派生 + Ed25519 签名。自定义二进制包格式(魔数 `ECC1`/`SIGN`),支持文本/字节/文件加解密。PIN 保护 PEM 密钥存储。
97
+ - **`Authenticator`** — TOTP 生成和验证,生成 `otpauth://` URI 和 ASCII 二维码。双阶段绑定流程:`get_secret()`(生成+展示)→ `verify(code)`(验证+持久化)。通过 `keyring` 存储密钥。
98
+ - **`PinManager`** — PBKDF2-HMAC-SHA256 PIN 哈希(200k 轮 + 16 字节随机盐),`keyring` 存储。
99
+ - **`send_email`** — 位于 `mailToPhone` 模块。通过 YAML 配置文件读取 SMTP 凭据,支持多服务商配置。配置路径:脚本同目录或 `~/.email_config.yaml`。
100
+ - **`to_test_func` / `make_timer` / `make_memory_monitor`** — 位于 `monitor_func` 模块。`to_test_func` 对任意可调用对象做耗时与峰值内存 benchmark;`make_timer` 闭包式性能计时;`make_memory_monitor` 进程 RSS 监控。
101
+ - **`get_resource_path`** / **`center_window`** / **`run_in_subprocess`** / **`run_in_subthread`** — 位于 `useful_func` 模块。资源路径解析(兼容 PyInstaller)、Tkinter 窗口居中辅助、子进程/子线程执行器(支持超时与异常透传)。
102
+
103
+ ### 约定
104
+
105
+ - `keyring` 不可用时所有安全模块自动回退到文件存储(`~/.<service>_<account>_*`,chmod 600)
106
+ - YAML 配置(邮件)优先读取可执行文件同目录,再回退用户 home 目录
107
+ - `src/` layout 布局,Hatchling 构建
108
+ - `web及数据工具/`、`实用工具/`、`邮件发送/` 为仓库根目录下的草稿/实验文件,**不包含在发布的包中**
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: raytoolsbox
3
+ Version: 2.0.1
4
+ Summary: Add your description here
5
+ Author: TIMLES@https://github.com/TIMLES
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: cryptography>=46.0.4
9
+ Requires-Dist: keyring>=25.7.0
10
+ Requires-Dist: psutil>=7.2.2
11
+ Requires-Dist: pyotp>=2.9.0
12
+ Requires-Dist: pyyaml>=6.0.3
13
+ Requires-Dist: qrcode>=8.2
14
+ Description-Content-Type: text/markdown
15
+
16
+
17
+ # raytoolsbox
18
+
19
+ 一个不断进化的 **个人 Python 工具合集(Toolbox)**。
20
+ 包含常用开发工具、实用脚本、个人算法、桌面应用助手、Web 小工具等。
21
+
22
+ 项目以 **模块化、可扩展、易维护** 为目标,为日常开发与个人项目提供稳定的工具支持。
23
+
24
+ ---
25
+
26
+ ## ✨ 特性(Features)
27
+
28
+ - 📧 **邮件工具**
29
+ 简洁易用的邮件发送函数,支持 QQ、Gmail 等多种 SMTP 服务,自动读取本地或用户目录的配置文件,自动处理 SSL、中文昵称等问题。
30
+
31
+ - 🔐 **现代化加密工具**
32
+ 使用 X25519 密钥交换 + ChaCha20-Poly1305 对称加密 + Ed25519 数字签名,支持文本、字节和文件的加密解密与签名验签。
33
+
34
+ - ⏱️ **性能监控工具**
35
+ 简易性能计时函数 `make_timer()` 与内存监控函数 `make_memory_monitor()`,
36
+ 以及完整 benchmark 测试工具 `to_test_func()`,适合代码性能分析和调试。
37
+
38
+ - 🖥️ **窗口工具**
39
+ Tkinter 窗口居中显示函数,兼容任意尺寸窗口。
40
+
41
+ - 📁 **资源路径工具**
42
+ 自动获取应用资源路径,兼容 PyInstaller 打包环境。
43
+
44
+ - ⚡ **子进程/子线程执行器**
45
+ `run_in_subprocess()` 和 `run_in_subthread()` 支持超时控制与异常透传,适合隔离危险操作或限制执行时间。
46
+
47
+ - 🧰 **更多工具持续加入中……**
48
+
49
+ ---
50
+
51
+ ## 📦 安装(Installation)
52
+
53
+ ### 使用 uv(推荐)
54
+ ```
55
+ uv add raytoolsbox
56
+ ```
57
+
58
+ ### 使用 pip
59
+ ```
60
+ pip install raytoolsbox
61
+ ```
62
+
63
+ ---
64
+
65
+ ## 🚀 快速开始(Quick Start)
66
+
67
+ ```python
68
+ from raytoolsbox.utils.mailToPhone import send_email
69
+ from raytoolsbox.utils.monitor_func import make_timer
70
+ from raytoolsbox.security.crypto_manager import CryptoManager
71
+
72
+ # 邮件发送
73
+ send_email(
74
+ subject="测试邮件",
75
+ content="<h1>Hello World</h1>",
76
+ to_addr="receiver@example.com",
77
+ serverName="Ray",
78
+ use_smtp="qq"
79
+ )
80
+
81
+ # 性能计时
82
+ tt = make_timer()
83
+ tt("开始任务")
84
+ # ... 执行代码 ...
85
+ tt("任务完成")
86
+
87
+ # 窗口居中
88
+ from raytoolsbox.utils.useful_func import center_window
89
+ center_window(window, 800, 600)
90
+
91
+ # 子进程执行(超时控制)
92
+ from raytoolsbox.utils.useful_func import run_in_subprocess, run_in_subthread
93
+ result = run_in_subthread(str.upper, "hello") # "HELLO"
94
+ result = run_in_subprocess(_add, 40, 2) # 42(函数需可 pickle)
95
+
96
+ # 加密解密
97
+ cm = CryptoManager(key_dir="./keys", PIN="your_password")
98
+ cm.generate_keys() # 生成密钥
99
+ encrypted = cm.encrypt("Hello", pubkey)
100
+ decrypted = cm.decrypt(encrypted)
101
+
102
+ # 数字签名
103
+ signed = cm.sign("重要数据", sign_key)
104
+ verified = cm.verify(signed, verify_key)
105
+ ```
106
+ ---
107
+
108
+ ## 📂 目录结构(Project Layout)
109
+
110
+ ```
111
+ raytoolsbox/
112
+ │
113
+ ├── pyproject.toml # 项目信息 + 依赖管理(uv)
114
+ ├── README.md # 项目文档
115
+ ├── src/
116
+ │ └── raytoolsbox/
117
+ │ ├── __init__.py
118
+ │ ├── utils/
119
+ │ │ ├── __init__.py
120
+ │ │ ├── useful_func.py # 资源路径、窗口居中、子进程/子线程执行器
121
+ │ │ ├── mailToPhone.py # 邮件发送工具
122
+ │ │ └── monitor_func.py # 性能计时器、内存监控、benchmark 测试
123
+ │ └── security/
124
+ │ ├── __init__.py
125
+ │ ├── crypto_manager.py # ECC 加密/签名工具
126
+ │ ├── authenticator.py
127
+ │ └── pin_manager.py
128
+ │
129
+ └── tests/
130
+ ├── test_authenticator.py # TOTP 认证测试
131
+ ├── test_crypto_manager.py # 加密/签名 + fuzz 测试
132
+ ├── test_mail_to_phone.py # 邮件发送测试
133
+ ├── test_monitor_func.py # 性能监控测试
134
+ ├── test_pin_manager.py # PIN 管理测试
135
+ └── test_useful_func.py # 路径/窗口/子进程工具测试
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 🧪 测试(Testing)
141
+
142
+ 本项目使用 pytest:
143
+
144
+ ```
145
+ uv run pytest
146
+ ```
147
+
148
+ 全部测试应通过:
149
+
150
+ ```
151
+ 58 passed
152
+ ```
153
+
154
+ ---
155
+
156
+ ## 🛠️ 开发路线图(Roadmap)
157
+
158
+ ### 已完成
159
+ - [x] 邮件发送工具封装(支持多 SMTP 服务)
160
+ - [x] 可本地覆盖的配置系统
161
+ - [x] pytest 自动化测试(mock 网络发送)
162
+ - [x] 现代化加密模块(X25519 + ChaCha20-Poly1305 + Ed25519)
163
+ - [x] 数字签名与验签功能
164
+ - [x] 计时工具
165
+ - [x] 窗口居中工具
166
+ - [x] 资源路径获取(PyInstaller 兼容)
167
+
168
+ ### 开发中 / 计划中
169
+ - [ ] 屏幕工具(DPI、尺寸测量)
170
+ - [ ] Tkinter / PySide6 GUI 工具类
171
+ - [ ] 文件操作工具(临时文件、下载器)
172
+ - [ ] 日期工具、定时工具、任务提醒系统
173
+ - [ ] 扩展 CLI(命令行使用工具箱)
174
+
175
+ 如果你有想加入的功能欢迎告诉我!
176
+
177
+ ---
178
+
179
+ ## 🤝 贡献(Contributing)
180
+
181
+ 欢迎 Issue 或 PR!
182
+ 可提交:
183
+
184
+ - Bug 报告
185
+ - 新功能建议
186
+ - 工具模块
187
+ - 文档改进
188
+
189
+ ---
190
+
191
+ ## 📄 License
192
+
193
+ 使用 MIT License,自由商用/修改/发布。
194
+
195
+ ---