Metadata-Version: 2.4
Name: raytoolsbox
Version: 2.0.1
Summary: Add your description here
Author: TIMLES@https://github.com/TIMLES
License: MIT
Requires-Python: >=3.11
Requires-Dist: cryptography>=46.0.4
Requires-Dist: keyring>=25.7.0
Requires-Dist: psutil>=7.2.2
Requires-Dist: pyotp>=2.9.0
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: qrcode>=8.2
Description-Content-Type: text/markdown


# raytoolsbox

一个不断进化的 **个人 Python 工具合集（Toolbox）**。  
包含常用开发工具、实用脚本、个人算法、桌面应用助手、Web 小工具等。

项目以 **模块化、可扩展、易维护** 为目标，为日常开发与个人项目提供稳定的工具支持。

---

## ✨ 特性（Features）

- 📧 **邮件工具**
  简洁易用的邮件发送函数，支持 QQ、Gmail 等多种 SMTP 服务，自动读取本地或用户目录的配置文件，自动处理 SSL、中文昵称等问题。

- 🔐 **现代化加密工具**
  使用 X25519 密钥交换 + ChaCha20-Poly1305 对称加密 + Ed25519 数字签名，支持文本、字节和文件的加密解密与签名验签。

- ⏱️ **性能监控工具**
  简易性能计时函数 `make_timer()` 与内存监控函数 `make_memory_monitor()`，
  以及完整 benchmark 测试工具 `to_test_func()`，适合代码性能分析和调试。

- 🖥️ **窗口工具**
  Tkinter 窗口居中显示函数，兼容任意尺寸窗口。

- 📁 **资源路径工具**
  自动获取应用资源路径，兼容 PyInstaller 打包环境。

- ⚡ **子进程/子线程执行器**
  `run_in_subprocess()` 和 `run_in_subthread()` 支持超时控制与异常透传，适合隔离危险操作或限制执行时间。

- 🧰 **更多工具持续加入中……**

---

## 📦 安装（Installation）

### 使用 uv（推荐）
```
uv add raytoolsbox
```

### 使用 pip
```
pip install raytoolsbox
```

---

## 🚀 快速开始（Quick Start）

```python
from raytoolsbox.utils.mailToPhone import send_email
from raytoolsbox.utils.monitor_func import make_timer
from raytoolsbox.security.crypto_manager import CryptoManager

# 邮件发送
send_email(
    subject="测试邮件",
    content="<h1>Hello World</h1>",
    to_addr="receiver@example.com",
    serverName="Ray",
    use_smtp="qq"
)

# 性能计时
tt = make_timer()
tt("开始任务")
# ... 执行代码 ...
tt("任务完成")

# 窗口居中
from raytoolsbox.utils.useful_func import center_window
center_window(window, 800, 600)

# 子进程执行（超时控制）
from raytoolsbox.utils.useful_func import run_in_subprocess, run_in_subthread
result = run_in_subthread(str.upper, "hello")      # "HELLO"
result = run_in_subprocess(_add, 40, 2)             # 42（函数需可 pickle）

# 加密解密
cm = CryptoManager(key_dir="./keys", PIN="your_password")
cm.generate_keys()  # 生成密钥
encrypted = cm.encrypt("Hello", pubkey)
decrypted = cm.decrypt(encrypted)

# 数字签名
signed = cm.sign("重要数据", sign_key)
verified = cm.verify(signed, verify_key)
```
---

## 📂 目录结构（Project Layout）

```
raytoolsbox/
│
├── pyproject.toml         # 项目信息 + 依赖管理（uv）
├── README.md              # 项目文档
├── src/
│   └── raytoolsbox/
│       ├── __init__.py
│       ├── utils/
│       │   ├── __init__.py
│       │   ├── useful_func.py    # 资源路径、窗口居中、子进程/子线程执行器
│       │   ├── mailToPhone.py   # 邮件发送工具
│       │   └── monitor_func.py  # 性能计时器、内存监控、benchmark 测试
│       └── security/
│           ├── __init__.py
│           ├── crypto_manager.py # ECC 加密/签名工具
│           ├── authenticator.py
│           └── pin_manager.py
│
└── tests/
    ├── test_authenticator.py  # TOTP 认证测试
    ├── test_crypto_manager.py # 加密/签名 + fuzz 测试
    ├── test_mail_to_phone.py  # 邮件发送测试
    ├── test_monitor_func.py   # 性能监控测试
    ├── test_pin_manager.py    # PIN 管理测试
    └── test_useful_func.py    # 路径/窗口/子进程工具测试
```

---

## 🧪 测试（Testing）

本项目使用 pytest：

```
uv run pytest
```

全部测试应通过：

```
58 passed
```

---

## 🛠️ 开发路线图（Roadmap）

### 已完成
- [x] 邮件发送工具封装（支持多 SMTP 服务）
- [x] 可本地覆盖的配置系统
- [x] pytest 自动化测试（mock 网络发送）
- [x] 现代化加密模块（X25519 + ChaCha20-Poly1305 + Ed25519）
- [x] 数字签名与验签功能
- [x] 计时工具
- [x] 窗口居中工具
- [x] 资源路径获取（PyInstaller 兼容）

### 开发中 / 计划中
- [ ] 屏幕工具（DPI、尺寸测量）
- [ ] Tkinter / PySide6 GUI 工具类
- [ ] 文件操作工具（临时文件、下载器）
- [ ] 日期工具、定时工具、任务提醒系统
- [ ] 扩展 CLI（命令行使用工具箱）

如果你有想加入的功能欢迎告诉我！

---

## 🤝 贡献（Contributing）

欢迎 Issue 或 PR！  
可提交：

- Bug 报告  
- 新功能建议  
- 工具模块  
- 文档改进  

---

## 📄 License

使用 MIT License，自由商用/修改/发布。

---
