版本:2.1.8
易加密小工具 - 常用密码学操作命令行工具,支持 AES、SM4、RSA、ECC、SM2、ZUC、哈希、HMAC、证书解析等。
- 快速入门
- 主命令与全局帮助
- version - 版本信息
- aes - AES 加解密
- sm4 - SM4 国密加解密
- random-str - 随机字符串生成
- hash - 哈希摘要
- hmac - HMAC 消息验证码
- rsa - RSA 加解密与签名验签
- ecc - ECC 签名验签与密钥交换
- sm2 - SM2 国密加解密与签名验签
- zuc - ZUC 祖冲之流密码
- cert-parse - 证书解析
1. 快速入门#
1.1 安装与调用#
1
2
3
| # 安装后可通过以下方式调用
pip install easy-encryption-tool\[gmssl\] --upgrade
easy_encryption_tool --help
|

1.2 常用示例#

1
2
3
4
5
6
7
8
9
10
11
| # AES 加密
easy_encryption_tool aes -a encrypt -i 'hello'
# 生成 32 位随机串
easy_encryption_tool random-str -l 32
# SHA256 哈希
easy_encryption_tool hash -i 'data' -a sha256
# 查看版本
easy_encryption_tool version
|
2. 主命令与全局帮助#
2.1 主命令#
| 命令 | 说明 |
|---|
easy_encryption_tool | 主入口,无子命令时显示引导提示 |
easy_encryption_tool --help | 显示所有子命令列表 |
2.2 示例#
1
2
| # 显示主帮助
easy_encryption_tool --help
|
说明:直接运行 easy_encryption_tool 会显示常用命令示例;带 --help 会列出所有子命令。
3. version - 版本信息#
3.1 功能说明#
展示当前工具版本、Python 版本、操作系统、处理器架构、字节序及 CipherHUB 官网信息。

3.2 命令格式#
1
| easy_encryption_tool version
|
3.3 参数说明#
本命令无参数。
3.4 示例#
1
| easy_encryption_tool version
|
输出示例:
1
2
3
4
5
6
7
| tool-version:v2.0.7
python:3.12.x
os:darwin
chip:...
byte-order:little
website:https://cipherhub.cloud
tagline:Serious Cryptography · Creative Solutions · Mapping Digital Trust
|
4. aes - AES 加解密#
4.1 功能说明#
AES 对称加解密工具,支持 AES-CBC-256 和 AES-GCM-256 模式。加密输出为 Base64 编码;解密支持 Base64 密文或文件。与 CipherHUB 默认参数兼容。


4.2 命令格式#
1
| easy_encryption_tool aes [OPTIONS] -i INPUT_DATA
|
4.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--mode | -m | choice | 否 | cbc | AES 模式:cbc 或 gcm |
--key | -k | string | 否 | 32 字节默认 | 密钥,256 位;不足补齐、超出截取 |
--iv-nonce | -v | string | 否 | 16/12 字节默认 | CBC 下 IV 16 字节,GCM 下 nonce 12 字节 |
--aad | - | string | 否 | CipherHUB 默认 | GCM 模式关联认证数据 AAD |
--random-key-iv | -r | flag | 否 | False | 自动生成随机密钥和 IV/nonce |
--action | -a | choice | 否 | encrypt | 操作:encrypt 或 decrypt |
--input-data | -i | string | 是 | - | 输入数据:明文/密文/文件路径 |
--is-base64-encoded | -e | flag | 否 | False | 输入为 Base64 编码(与 -f 互斥) |
--is-a-file | -f | flag | 否 | False | 输入为文件路径(与 -e 互斥) |
--input-limit | -l | int | 否 | 1 | 非文件时最大输入长度(MB) |
--output-file | -o | string | 否 | - | 输出文件路径,文件输入时必须指定 |
--no-force | - | flag | 否 | False | 不覆盖已存在的输出文件 |
--gcm-pad | - | flag | 否 | False | [仅 GCM 模式] 加密前对明文做 PKCS#7 填充、解密后去除填充。默认不填充,与 CipherHUB stream_cipher 兼容;加密/解密需一致使用 |
4.4 GCM 模式与填充说明#
- CBC 模式:始终对明文做 PKCS#7 填充(块密码要求)。
- GCM 模式:默认不对明文做 PKCS#7 填充,直接加密原始数据,与 CipherHUB stream_cipher 行为一致。
- 若需 GCM 模式下使用 PKCS#7 填充(例如与某些旧实现兼容),请加
--gcm-pad。加密与解密必须同时使用或同时不使用 --gcm-pad,否则解密会失败。
4.5 输入数据约定#
- 默认:
-i 为 UTF-8 明文字符串 -e:-i 为 Base64 编码数据-f:-i 为文件路径;此时必须指定 -o
4.6 示例#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| # 使用默认 CBC 模式加密明文字符串
easy_encryption_tool aes -a encrypt -i 'hello'
# 使用 GCM 模式加密(默认无填充,与 CipherHUB 兼容)
easy_encryption_tool aes -m gcm -a encrypt -i 'hello'
# GCM 模式启用 PKCS#7 填充(加密与解密需一致使用 --gcm-pad)
easy_encryption_tool aes -m gcm -a encrypt -i 'hello' --gcm-pad
# 使用随机密钥和 IV 加密
easy_encryption_tool aes -r -a encrypt -i 'hello'
# 解密 Base64 密文(需先加 -e 表示密文为 Base64)
easy_encryption_tool aes -a decrypt -i 'BASE64_CIPHER_STRING' -e
# 加密文件并输出到指定文件
easy_encryption_tool aes -a encrypt -i /path/to/input.txt -f -o /path/to/output.bin
# 解密文件
easy_encryption_tool aes -a decrypt -i /path/to/cipher.bin -f -o /path/to/plain.txt -e
# 不覆盖已存在的输出文件
easy_encryption_tool aes -a encrypt -i 'data' -o out.bin --no-force
|
5. sm4 - SM4 国密加解密#
5.1 功能说明#
SM4 国密对称加解密,支持 SM4-CBC 和 SM4-GCM 模式。需安装 easy_gmssl 依赖。


5.2 命令格式#
1
| easy_encryption_tool sm4 [OPTIONS] -i INPUT_DATA
|
5.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--mode | -m | choice | 否 | cbc | 模式:cbc 或 gcm |
--key | -k | string | 否 | 16 字节默认 | 密钥 16 字节 |
--iv-nonce | -v | string | 否 | 16/12 字节默认 | CBC 下 IV 16 字节,GCM 下 nonce 12 字节 |
--aad | - | string | 否 | CipherHUB 默认 | GCM 模式 AAD |
--random-key-iv | -r | flag | 否 | False | 随机生成密钥和 IV/nonce |
--action | -a | choice | 否 | encrypt | encrypt 或 decrypt |
--input-data | -i | string | 是 | - | 输入数据 |
--is-base64-encoded | -e | flag | 否 | False | 输入为 Base64 |
--is-a-file | -f | flag | 否 | False | 输入为文件 |
--input-limit | -l | int | 否 | 1 | 非文件时最大输入(MB) |
--output-file | -o | string | 否 | - | 文件输入时必须指定 |
--no-force | - | flag | 否 | False | 不覆盖已存在输出文件 |
--gcm-pad | - | flag | 否 | False | [仅 GCM 模式] 加密前对明文做 PKCS#7 填充、解密后去除填充。默认不填充;加密/解密需一致使用 |
5.4 GCM 模式与填充说明#
- CBC 模式:始终对明文做 PKCS#7 填充。
- GCM 模式:默认不对明文做 PKCS#7 填充,与 CipherHUB stream_cipher 兼容。若需填充,使用
--gcm-pad,加密与解密必须一致。
5.5 示例#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| # SM4-CBC 加密
easy_encryption_tool sm4 -a encrypt -i '你好'
# SM4-GCM 加密(默认无填充)
easy_encryption_tool sm4 -m gcm -a encrypt -i 'hello'
# SM4-GCM 启用 PKCS#7 填充
easy_encryption_tool sm4 -m gcm -a encrypt -i 'hello' --gcm-pad
# 随机密钥加密
easy_encryption_tool sm4 -r -a encrypt -i 'data'
# 解密 Base64 密文
easy_encryption_tool sm4 -a decrypt -i 'BASE64_CIPHER' -e
# 文件加解密
easy_encryption_tool sm4 -a encrypt -i input.txt -f -o cipher.bin
easy_encryption_tool sm4 -a decrypt -i cipher.bin -f -o plain.txt -e
|
6. random-str - 随机字符串生成#
6.1 功能说明#
使用密码学安全随机数(CSPRNG)生成随机字符串,可用于密钥、IV、令牌等。

6.2 命令格式#
1
| easy_encryption_tool random-str [OPTIONS]
|
6.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--length | -l | int | 否 | 32 | 生成字符串长度(1 至系统最大整型) |
--output-file | -o | string | 否 | - | 输出到文件 |
--no-force | - | flag | 否 | False | 不覆盖已存在输出文件 |
6.4 示例#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # 生成 32 位随机串(默认)
easy_encryption_tool random-str
# 生成 64 位随机串
easy_encryption_tool random-str -l 64
# 生成 16 位随机串
easy_encryption_tool random-str -l 16
# 输出到文件
easy_encryption_tool random-str -l 32 -o random_key.txt
# 不覆盖已有文件
easy_encryption_tool random-str -l 32 -o key.txt --no-force
|
7. hash - 哈希摘要#
7.1 功能说明#
计算哈希摘要,支持 SM3、SHA256、SHA384、SHA512。SM3 需 easy_gmssl。

7.2 命令格式#
1
| easy_encryption_tool hash [OPTIONS] -i INPUT_DATA
|
7.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--input-data | -i | string | 是 | - | 输入:字符串、Base64 或文件路径 |
--is-base64-encoded | -e | flag | 否 | False | 输入为 Base64(与 -f 互斥) |
--is-a-file | -f | flag | 否 | False | 输入为文件路径(与 -e 互斥) |
--hash-alg | -a | choice | 否 | sha256 | 算法:sm3、sha256、sha384、sha512 |
7.4 示例#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # SHA256 哈希(默认)
easy_encryption_tool hash -i 'hello'
# SM3 哈希
easy_encryption_tool hash -i 'hello' -a sm3
# SHA384 哈希
easy_encryption_tool hash -i 'data' -a sha384
# 对 Base64 编码数据哈希
easy_encryption_tool hash -i 'aGVsbG8=' -e -a sha256
# 对文件计算哈希
easy_encryption_tool hash -i /path/to/file.bin -f -a sha256
|
8. hmac - HMAC 消息验证码#
8.1 功能说明#
计算 HMAC 消息验证码,支持 SM3、SHA224、SHA256、SHA384、SHA512、SHA3 系列。SM3 需 easy_gmssl。

8.2 命令格式#
1
| easy_encryption_tool hmac [OPTIONS] -i INPUT_DATA
|
8.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--input-data | -i | string | 是 | - | 输入数据 |
--is-base64-encoded | -e | flag | 否 | False | 输入为 Base64 |
--is-a-file | -f | flag | 否 | False | 输入为文件 |
--hash-alg | -a | choice | 否 | sha256 | 哈希算法 |
--key | -k | string | 否 | 32 字节默认 | HMAC 密钥 |
--random-key | -r | flag | 否 | False | 自动生成 32 字节随机密钥 |
8.4 示例#
1
2
3
4
5
6
7
8
9
10
11
| # 使用默认 SHA256 和默认密钥
easy_encryption_tool hmac -i 'hello'
# 指定密钥和 SM3
easy_encryption_tool hmac -i 'data' -k 'my_secret_key_32_bytes_long!!!!' -a sm3
# 随机密钥
easy_encryption_tool hmac -i 'hello' -r
# 对文件计算 HMAC
easy_encryption_tool hmac -i /path/to/file -f -a sha256
|
9. rsa - RSA 加解密与签名验签#

9.1 子命令概览#
| 子命令 | 说明 |
|---|
generate | 生成 RSA 密钥对 |
encrypt | 公钥加密 |
decrypt | 私钥解密 |
sign | 私钥签名 |
verify | 公钥验签 |
9.2 rsa generate - 生成密钥对#
命令格式#
1
| easy_encryption_tool rsa generate [OPTIONS]
|
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--size | -s | choice | 否 | 2048 | 密钥位数:2048、3072、4096 |
--encoding | -e | choice | 否 | pem | 格式:pem 或 der |
--file-name | -f | string | 是 | demo | 输出文件名前缀 |
--password | -p | string | 否 | - | 私钥密码 |
--random-password | -r | flag | 否 | False | 生成 32 字节随机私钥密码 |
1
2
3
4
5
6
7
8
9
10
11
| # 生成 2048 位 RSA 密钥对,输出 demo_rsa_public.pem / demo_rsa_private.pem
easy_encryption_tool rsa generate -f demo
# 生成 4096 位密钥对
easy_encryption_tool rsa generate -s 4096 -f my_rsa
# 带密码保护
easy_encryption_tool rsa generate -f demo -p 'my_password'
# 随机密码
easy_encryption_tool rsa generate -f demo -r
|
9.3 rsa encrypt - 公钥加密#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--public-key | -f | string | 是 | - | 公钥文件路径 |
--input-data | -i | string | 是 | - | 明文(字符串或 Base64) |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--input-limit | -l | int | 否 | 1 | 最大输入长度(MB) |
--mode | -m | choice | 否 | oaep | 填充:oaep 或 pkcs1v15 |
--hash-mode | -h | choice | 否 | sha256 | OAEP 时哈希:sha1/sha224/sha256/sha384/sha512 |
1
2
3
4
5
6
7
8
| # 使用 OAEP+SHA256 加密
easy_encryption_tool rsa encrypt -f demo_rsa_public.pem -i 'hello'
# 使用 PKCS1v15
easy_encryption_tool rsa encrypt -f pub.pem -i 'data' -m pkcs1v15
# 输入为 Base64
easy_encryption_tool rsa encrypt -f pub.pem -i 'aGVsbG8=' -c
|
9.4 rsa decrypt - 私钥解密#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--private-key | -f | string | 是 | - | 私钥文件路径 |
--input-data | -i | string | 是 | - | Base64 密文 |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--mode | -m | choice | 否 | oaep | 填充模式 |
--hash-mode | -h | choice | 否 | sha256 | OAEP 哈希 |
--password | -p | string | 否 | - | 私钥密码 |
1
2
3
4
5
| # 解密
easy_encryption_tool rsa decrypt -f demo_rsa_private.pem -i 'BASE64_CIPHER'
# 带密码
easy_encryption_tool rsa decrypt -f pri.pem -i 'CIPHER' -p 'my_password'
|
9.5 rsa sign - 私钥签名#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--private-key | -f | string | 是 | - | 私钥文件路径 |
--input-data | -i | string | 是 | - | 待签名数据 |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--mode | -m | choice | 是 | pss | 填充:pss 或 pkcs1v15 |
--hash-mode | -h | choice | 否 | sha256 | 哈希算法 |
--password | -p | string | 否 | - | 私钥密码 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--input-is-digest | -d | flag | 否 | False | 输入为预计算摘要 |
1
2
3
4
5
6
7
8
| # PSS 签名
easy_encryption_tool rsa sign -f pri.pem -i 'hello' -m pss
# PKCS1v15 签名
easy_encryption_tool rsa sign -f pri.pem -i 'data' -m pkcs1v15
# 对摘要签名
easy_encryption_tool rsa sign -f pri.pem -i 'HEX_DIGEST_32_BYTES' -d -h sha256
|
9.6 rsa verify - 公钥验签#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--public-key | -f | string | 是 | - | 公钥文件路径 |
--input-data | -i | string | 是 | - | 被验签数据 |
--signature | -s | string | 是 | - | Base64 签名值 |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--mode | -m | choice | 是 | pss | 填充模式 |
--hash-mode | -h | choice | 否 | sha256 | 哈希算法 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--input-is-digest | -d | flag | 否 | False | 输入为预计算摘要 |
1
2
| # 验签
easy_encryption_tool rsa verify -f pub.pem -i 'hello' -s 'BASE64_SIGNATURE' -m pss
|
10. ecc - ECC 签名验签与密钥交换#

10.1 子命令概览#
| 子命令 | 说明 |
|---|
generate | 生成 ECC 密钥对 |
ecdh | ECDH 密钥交换 |
sign | ECC 签名 |
verify | ECC 验签 |
10.2 ecc generate - 生成密钥对#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--curve | -c | choice | 否 | secp256k1 | 曲线:secp256r1/secp384r1/secp521r1/secp256k1 |
--encoding | -e | choice | 否 | pem | 格式:pem/der |
--file-name | -f | string | 是 | demo | 输出文件名前缀 |
--password | -p | string | 否 | - | 私钥密码 |
--random-password | -r | flag | 否 | False | 随机私钥密码 |
1
2
3
4
5
| # 生成 secp256k1 密钥对
easy_encryption_tool ecc generate -f demo
# 指定曲线
easy_encryption_tool ecc generate -c secp256r1 -f alice
|
10.3 ecc ecdh - 密钥交换#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--alice-pub-key | -a | string | 是 | - | 己方公钥路径 |
--alice-pri-key | -k | string | 是 | - | 己方私钥路径 |
--bob-pub-key | -b | string | 是 | - | 对方公钥路径 |
--password | -p | string | 否 | - | 己方私钥密码 |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--length | -l | int | 否 | 32 | 派生密钥长度(16-64) |
--hash-mode | -h | choice | 否 | sha512 | HKDF 哈希 |
--salt | -s | string | 否 | CipherHUB 默认 | HKDF 盐值 |
--context | -c | string | 否 | CipherHUB 默认 | HKDF 附加信息 |
1
2
3
4
5
| # 执行 ECDH 密钥交换
easy_encryption_tool ecc ecdh -a alice_public.pem -k alice_private.pem -b bob_public.pem
# 带私钥密码
easy_encryption_tool ecc ecdh -a alice_pub.pem -k alice_pri.pem -b bob_pub.pem -p 'password'
|
10.4 ecc sign / ecc verify#
参数说明(sign)#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--private-key | -f | string | 是 | - | 私钥路径 |
--input-data | -i | string | 是 | - | 待签名数据 |
--encoding | -e | choice | 否 | pem | 密钥格式 |
--hash-mode | -h | choice | 否 | sha512 | 哈希算法 |
--password | -p | string | 否 | - | 私钥密码 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--input-is-digest | -d | flag | 否 | False | 输入为预计算摘要 |
参数说明(verify)#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--public-key | -f | string | 是 | - | 公钥路径 |
--input-data | -i | string | 是 | - | 被验签数据 |
--signature | -s | string | 是 | - | Base64 签名 |
| 其他 | - | - | - | - | 同 sign |
1
2
3
4
5
| # 签名
easy_encryption_tool ecc sign -f pri.pem -i 'hello'
# 验签
easy_encryption_tool ecc verify -f pub.pem -i 'hello' -s 'BASE64_SIG'
|
11. sm2 - SM2 国密加解密与签名验签#

需安装 easy_gmssl。
11.1 子命令概览#
| 子命令 | 说明 |
|---|
generate | 生成 SM2 密钥对 |
encrypt | 公钥加密 |
decrypt | 私钥解密 |
sign | 私钥签名 |
verify | 公钥验签 |
11.2 sm2 generate#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--file-name | -f | string | 是 | demo | 输出文件名前缀 |
--password | -p | string | 否 | - | 私钥密码(1-32 字节,必填或使用 -r) |
--random-password | -r | flag | 否 | False | 生成 32 字节随机密码 |
1
2
3
4
5
| # 生成 SM2 密钥对(必须指定密码或 -r)
easy_encryption_tool sm2 generate -f demo -p '12345678'
# 随机密码
easy_encryption_tool sm2 generate -f demo -r
|
11.3 sm2 encrypt#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--public-key | -f | string | 是 | - | 公钥文件路径 |
--input-data | -i | string | 是 | - | 明文 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--cipher-mode | -m | choice | 否 | C1C3C2_ASN1 | 密文格式:C1C3C2_ASN1/C1C3C2/C1C2C3_ASN1/C1C2C3 |
--output-format | -o | choice | 否 | base64 | 输出:base64 或 hex |
--input-limit | -l | int | 否 | 1 | 最大输入(MB) |
1
| easy_encryption_tool sm2 encrypt -f demo_sm2_public.pem -i 'hello'
|
11.4 sm2 decrypt#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--private-key | -f | string | 是 | - | 私钥路径 |
--input-data | -i | string | 是 | - | 密文(Base64 或 hex) |
--hex-input | -x | flag | 否 | False | 输入为 hex |
--cipher-mode | -m | choice | 否 | C1C3C2_ASN1 | 密文格式 |
--password | -p | string | 是 | - | 私钥密码 |
1
| easy_encryption_tool sm2 decrypt -f demo_sm2_private.pem -i 'BASE64_CIPHER' -p '12345678'
|
11.5 sm2 sign#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--private-key | -f | string | 是 | - | 私钥路径 |
--input-data | -i | string | 是 | - | 待签名数据 |
--b64-encoded | -c | flag | 否 | False | 输入为 Base64 |
--input-is-digest | -d | flag | 否 | False | 输入为 SM3 摘要(32 字节) |
--signature-mode | -m | choice | 否 | RS_ASN1 | 签名格式:RS_ASN1 或 RS |
--password | -p | string | 是 | - | 私钥密码 |
--signer-id | - | string | 否 | 1234567812345678 | SM2 用户标识 |
1
| easy_encryption_tool sm2 sign -f pri.pem -i 'hello' -p 'password'
|
11.6 sm2 verify#
参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--public-key | -f | string | 是 | - | 公钥路径 |
--input-data | -i | string | 是 | - | 被验签数据 |
--signature | -s | string | 是 | - | 签名(Base64 或 hex) |
--sig-b64 / --sig-hex | - | flag | - | sig-b64 | 签名编码格式 |
| 其他 | - | - | - | - | 同 sign |
1
| easy_encryption_tool sm2 verify -f pub.pem -i 'hello' -s 'BASE64_SIG' -p 'password'
|
12. zuc - ZUC 祖冲之流密码#

12.1 功能说明#
ZUC 流密码加解密,密钥和 IV 均为 16 字节。密文与明文等长。需 easy_gmssl。
12.2 命令格式#
1
| easy_encryption_tool zuc [OPTIONS] -i INPUT_DATA
|
12.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--key | -k | string | 否 | 16 字节默认 | 密钥 |
--iv | -v | string | 否 | 16 字节默认 | IV |
--random-key-iv | -r | flag | 否 | False | 随机生成密钥和 IV |
--action | -a | choice | 否 | encrypt | encrypt 或 decrypt |
--input-data | -i | string | 是 | - | 输入数据 |
--is-base64-encoded | -e | flag | 否 | False | 输入为 Base64 |
--is-a-file | -f | flag | 否 | False | 输入为文件 |
--input-limit | -l | int | 否 | 1 | 非文件时最大输入(MB) |
--output-file | -o | string | 否 | - | 文件输入时必须指定 |
--no-force | - | flag | 否 | False | 不覆盖已存在输出 |
12.4 示例#
1
2
3
4
5
6
7
8
9
10
11
| # 加密
easy_encryption_tool zuc -a encrypt -i 'hello'
# 随机密钥加密
easy_encryption_tool zuc -r -a encrypt -i 'data'
# 解密
easy_encryption_tool zuc -a decrypt -i 'BASE64_CIPHER' -e
# 文件加解密
easy_encryption_tool zuc -a encrypt -i input.bin -f -o output.bin
|
13. cert-parse - 证书解析#

13.1 功能说明#
解析 PEM 或 DER 格式的 X.509 证书,支持国际算法及国密 SM2 证书。可验证证书签名(通过 AIA 获取 CA)。
13.2 命令格式#
1
| easy_encryption_tool cert-parse [OPTIONS] -f CERT_FILE
|
13.3 参数说明#
| 参数 | 短选项 | 类型 | 必填 | 默认值 | 说明 |
|---|
--cert-file | -f | string | 是 | - | 证书文件路径 |
--encoding | -e | choice | 是 | pem | 格式:pem 或 der |
--gm-cert | -g | flag | 否 | False | 按国密 SM2 证书解析(仅 PEM) |
--verbose | -v | flag | 否 | False | 显示详细信息 |
13.4 示例#
1
2
3
4
5
6
7
8
9
10
11
| # 解析 PEM 证书
easy_encryption_tool cert-parse -f /path/to/cert.pem -e pem
# 解析 DER 证书
easy_encryption_tool cert-parse -f cert.der -e der
# 解析国密 SM2 证书
easy_encryption_tool cert-parse -f sm2_cert.pem -e pem -g
# 显示详细信息
easy_encryption_tool cert-parse -f cert.pem -e pem -v
|
附录 A:通用约定#
A.1 输入数据标识#
- 默认:
-i 为 UTF-8 明文字符串 -e / --is-base64-encoded:输入为 Base64-f / --is-a-file:输入为文件路径
-e 与 -f 互斥,不可同时使用。
A.2 文件操作#
- 输入为文件时,通常需指定
-o 输出文件 - 默认会覆盖已存在输出文件;使用
--no-force 可禁止覆盖
A.3 国密算法依赖#
SM2、SM3、SM4、ZUC 等国密算法需安装 easy_gmssl:
A.4 CipherHUB 兼容#
工具默认参数与 CipherHUB 保持一致,便于与 Web/API 互操作。
附录 B:命令速查表#
| 命令 | 用途 |
|---|
version | 版本信息 |
aes | AES-CBC/GCM 加解密 |
sm4 | SM4-CBC/GCM 加解密 |
random-str | 随机字符串 |
hash | 哈希摘要 |
hmac | HMAC |
rsa generate/encrypt/decrypt/sign/verify | RSA 操作 |
ecc generate/ecdh/sign/verify | ECC 操作 |
sm2 generate/encrypt/decrypt/sign/verify | SM2 操作 |
zuc | ZUC 流密码 |
cert-parse | 证书解析 |