seckit4j/README.md
2026-06-23 11:29:46 +08:00

29 lines
1.3 KiB
Markdown
Raw 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.

# sectool
`sectool` 当前统一入口为 `com.sunyard.cisd.device.tool.Main``pom.xml` 已配置打包后的 `Main-Class` 指向该类。
## 支持功能
- `genkey`:生成 SM2 密钥对,输出 Base64 编码的 PKCS#8 私钥和 X.509 公钥。
- `env-create`:生成普通 SM2 数字信封。
- `env-open`:解密普通 SM2 数字信封。
- `signed-env-create`:生成带签名的 SM2 数字信封。
- `signed-env-open`:解密并验证带签名的 SM2 数字信封。
## 使用方式
```bash
java -jar target/sectool-1.0.3-jar-with-dependencies.jar genkey
java -jar target/sectool-1.0.3-jar-with-dependencies.jar env-create <publicKeyBase64> <text|@file>
java -jar target/sectool-1.0.3-jar-with-dependencies.jar env-open <privateKeyBase64> <envelopeBase64|@file>
java -jar target/sectool-1.0.3-jar-with-dependencies.jar signed-env-create <signPrivateKeyBase64> <encryptPublicKeyBase64> <text|@file>
java -jar target/sectool-1.0.3-jar-with-dependencies.jar signed-env-open <decryptPrivateKeyBase64> <signPublicKeyBase64> <envelopeBase64|@file>
```
说明:`@file` 表示从 UTF-8 文件读取输入内容;命令输出的数字信封均为 Base64。
## 测试用例
- `1-1`:普通 SM2 数字信封生成和解密。
- `1-2`:带签名 SM2 数字信封生成、解密和验签。