Skip to main content

Tuomin - Excel 脱敏工具

命令行工具,对 xls/xlsx 文件中的个人敏感信息进行脱敏处理。

安装

uv tool install tuomin

Python >= 3.8

也可使用 pip install tuomin

开发

git clone https://github.com/annopick/tuomin.git
cd tuomin
uv sync

用法

tuomin <input_file> --col <列字母>:<字段类型>:<脱敏方式> [--col ...] [选项]

参数

参数 说明
input_file 输入的 xls/xlsx 文件路径
--sheet Sheet 名称或索引(从 0 开始),默认第一个 Sheet
--col 指定脱敏列,格式 列字母:字段类型:脱敏方式,可多次使用
--output 输出文件路径,默认在同目录生成 _masked.xlsx 后缀文件

字段类型

标识 说明
name 姓名
phone 手机号
idcard 身份证号
email 邮箱
bankcard 银行卡号
address 地址

脱敏方式

标识 说明
replace 用 * 替换敏感部分,保留部分原文特征
reconstruct 生成与现实无关的假数据

示例

替换单列手机号:

tuomin data.xlsx --col C:phone:replace

重构多列:

tuomin data.xls --col B:name:reconstruct --col D:idcard:reconstruct --output result.xlsx

指定 Sheet + 混合脱敏:

tuomin data.xlsx --sheet 员工信息 --col B:name:replace --col C:phone:reconstruct --col E:email:replace

替换规则

字段类型 保留规则 示例
姓名 保留姓,名用 * 张三丰 → 张**
手机号 保留前 3 后 4 13812341234 → 138****1234
身份证号 保留前 3 后 4 310101199001011234 → 310***********1234
邮箱 首字符 + * + 域名 zhangsan@qq.com → z*******@qq.com
银行卡号 保留前 4 后 4 6222021234565678 → 6222********5678
地址 保留到区/县 上海市浦东新区张江路88号 → 上海市浦东新区******

重构规则

生成的假数据不可能对应任何真实信息:

字段类型 生成规则 示例
姓名 姓氏 + 中文数字 张三四
手机号 110 开头(报警号段) 11056781234
身份证号 999 开头(不存在的地区码) 999999199901019923
邮箱 @notexist.invalid a3k9x@notexist.invalid
银行卡号 0000 开头(不存在的 BIN) 0000123456781234
地址 虚构路 + 数字号 广东省深圳市虚构路999号

特性

  • 一致性 — 同一原文在同一列中始终映射到相同结果
  • 叠加重构 — 对已包含 * 的替换数据可再次重构
  • 空值/非标准值 — 原样保留,不报错
  • 编码兼容 — 自动处理 xls GBK 编码和控制台输出编码
  • 安全 — 永不覆盖原文件,始终生成新文件
  • 格式统一 — 输出始终为 xlsx

Metadata

Release files for tuomin 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tuomin 0.1.3
File Size Uploaded
tuomin-0.1.3.tar.gz 22.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tuomin 0.1.3
File Interpreter ABI Platform
tuomin-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / tuomin-0.1.3.tar.gz

Download URL tuomin-0.1.3.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
062b093ac21c2497b309b4162b797693447146ccbd3113891bb518390d2fc20b
BLAKE2b-256 checksum
How to use checksums
f459c16e7140dafc109c29b206769300eedd8ae4fdc68cae988f215ed8f6ec37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 14, 2026.

Transparency log

Release files / tuomin-0.1.3-py3-none-any.whl

Download URL tuomin-0.1.3-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6272b5f5494ab4add5e89c3403005f23369f6ce0a50f2e2d2e4e72f59b232b3
BLAKE2b-256 checksum
How to use checksums
af2675382f1f8ce72d743e49ae7a3d34b4e82458cbc731202ad7693907db9127
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page