Metadata-Version: 2.4
Name: svg2text
Version: 1.0.0
Summary: Lossless SVG compression and encryption for the command line
Keywords: svg,compression,encryption,cli
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Topic :: Multimedia :: Graphics
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: brotli==1.2.0
Requires-Dist: cryptography==50.0.1

# svg2text (Python)

无损压缩和加密 SVG 文件的命令行工具。编码流程为 Brotli → AES-256-GCM → Base64URL，解码后还原原始字节。此 Python 实现与同名 Rust 命令行程序使用兼容的 SVG1 格式。

## 安装

```sh
python3 -m pip install svg2text
```

安装后可使用 `svg2text` 命令。需要 Python 3.9 或更高版本；pip 会安装 Brotli 和 cryptography 依赖。

## 使用

```sh
svg2text encode input.svg -k 'your-password' -o output.txt
svg2text decode output.txt -k 'your-password' -o restored.svg
```

省略 `-o` 会写入标准输出；输入路径 `-` 从标准输入读取。也可以通过 `SVG2TEXT_KEY` 环境变量提供口令。交互终端中未提供口令时会提示输入。已有输出文件不会被覆盖。

Python 代码也可以直接调用：

```python
from svg_codec import encode, decode

token = encode(b"<svg/>", "your-password")
original = decode(token, "your-password")
```

输入及解压结果上限为 16 MiB。短口令容易被穷举；在命令行中直接传入口令也可能将其留在 shell 历史中。

## 从源码运行和测试

在仓库根目录运行：

```sh
uv run --script python/svg_codec.py encode examples/slide1_overview.svg -k 769012 -o output.txt
python3 -m pip install ./python
python3 -m unittest discover -s python -v
```
