ai_member_xiaoxi/memory/2026-06-03-1413.md
2026-06-04 08:00:01 +08:00

106 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Session: 2026-06-03 14:13:50 GMT+8
- **Session Key**: agent:main:feishu:direct:ou_e63ce6b760ad39382852472f28fbe2a2
- **Session ID**: db61f0f5-442d-4804-adfa-ad619f609f70
- **Source**: feishu
## Conversation Summary
assistant: 解密结果:**15944281022**
user: 你会手机号MD5加密么
assistant: 会的。Python 标准库 `hashlib` 直接就能做:
```python
import hashlib
hashlib.md5("13800138000".encode()).hexdigest()
```
需要我加密哪个手机号?发过来就行。
user: 我需要你帮我写一个脚本就是可以将bi_vala_app_account表里面的tel_encrypt通过上面的解密方式解密成手机号明文再用MD5加密。
assistant: 先确认一下:这个脚本的输出你希望是什么形式?
- **A)** 导出为 CSV 文件(`account_id, tel_encrypt, phone_md5`
- **B)** 直接更新回 `bi_vala_app_account` 表(新增一个 `phone_md5` 字段)
- **C)** 其他格式
另外是全量处理 `tel_encrypt` 不为空的所有记录对吧?
user: 导出为csv文件。另外我是希望可以在其他的skill里面调用这个脚本来实现对部分特定的用户的手机号的解密加密操作。
assistant: 明白了两件事1全量导出 CSV2提供可被其他 skill 调用的函数。
我先在 `phone_encrypt.py` 里加 MD5 函数,再写导出脚本。
assistant: 先验证一下脚本能跑通:
assistant: 加密解密 + MD5 都正常。测试一下导出脚本(先取少量数据验证):
assistant: 密码变量名是 `PG_ONLINE_PASSWORD`,修正一下:
assistant: 验证通过。确认下全量有多少条记录:
assistant: 全量 29489 条。现在登记到 SKILL_REGISTRY.md
assistant: 完成了。汇总如下:
---
### 改动内容
**1. `scripts/phone_encrypt.py` — 新增两个 MD5 函数**
```python
phone_md5(phone: str) -> str # 明文 → MD5
tel_encrypt_to_md5(tel_encrypt: str) # tel_encrypt → 解密 → MD5一步到位
```
**2. `scripts/export_phone_md5.py` — 导出脚本**
两种用法:
| 场景 | 命令 |
|------|------|
| 全量导出 | `python3 export_phone_md5.py` |
| 按 account_id 导出 | `python3 export_phone_md5.py --ids 57,308,100` |
| 指定输出路径 | `python3 export_phone_md5.py --output /path/to/out.csv` |
**被其他 skill 调用:**
```python
from scripts.export_phone_md5 import query_phone_md5
# 全量
results = query_phone_md5()
# 指定用户
results = query_phone_md5([57, 308, 100])
# 返回: [{account_id, tel_encrypt, phone_plain, phone_md5}, ...]
```
**输出 CSV 格式:** `account_id, tel_encrypt, phone_plain, phone_md5`
---
已验证通过,全量 **29,489 条**记录。要不要我现在跑一次全量导出?
user: 所以后面我应该用哪个脚本来实现tel_encrypt解密再MD5加密的操作呢
assistant: 直接用 `phone_encrypt.py`,核心函数都在这里面:
```python
from scripts.phone_encrypt import tel_encrypt_to_md5
md5 = tel_encrypt_to_md5("5WeooSK74KICOTX-LDEGhg..")
# → "ec7df1c501d154c5da6c873d9cb051e4"
```
`export_phone_md5.py` 是专门做全量/按ID导出 CSV 用的,它内部也是调 `phone_encrypt.py`。日常在其他 skill 里做解密+MD5只引 `phone_encrypt.py` 就够了,它现在提供了完整的四个函数:
| 函数 | 作用 |
|------|------|
| `encrypt_phone(phone)` | 明文 → tel_encrypt |
| `decrypt_phone(tel_encrypt)` | tel_encrypt → 明文 |
| `phone_md5(phone)` | 明文 → MD5 |
| `tel_encrypt_to_md5(tel_encrypt)` | tel_encrypt → 解密 → MD5一步到位 |