本文档枚举 easy_encryption_tool 支持的所有能力,提供输入参数和完整命令行,便于逐项执行并与 CipherHUB 比对结果。

默认测试数据(与 CipherHUB 兼容)

  • 明文:你好,密码学人 CipherHUB!
  • AES/SM4 key(32):01234567890123456789012345678901
  • AES/SM4 key(16):0123456789012345
  • IV(16):0123456789012345
  • Nonce(12):012345678901234567890123
  • AAD:密码学人 CipherHUB 默认 AAD 数据
  • ZUC key/iv:0123456789012345
  • HMAC key:01234567890123456789012345678901
  • SM2 signer_id:1234567812345678

1. version - 版本信息

序号能力输入参数完整命令行
1.1显示版本及运行时信息easy_encryption_tool version

2. random-str - 随机字符串生成

序号能力输入参数完整命令行
2.1生成 32 字节随机字符串(stdout)-l 32easy_encryption_tool random-str -l 32
2.2生成 64 字节随机字符串-l 64easy_encryption_tool random-str -l 64
2.3输出到文件-l 32 -o /tmp/rand.txteasy_encryption_tool random-str -l 32 -o /tmp/rand.txt

3. hash - 哈希摘要

序号能力输入参数完整命令行
3.1SHA256 字符串-i “你好,密码学人 CipherHUB!” -a sha256easy_encryption_tool hash -i "你好,密码学人 CipherHUB!" -a sha256
3.2SHA384 字符串-i “你好,密码学人 CipherHUB!” -a sha384easy_encryption_tool hash -i "你好,密码学人 CipherHUB!" -a sha384
3.3SHA512 字符串-i “你好,密码学人 CipherHUB!” -a sha512easy_encryption_tool hash -i "你好,密码学人 CipherHUB!" -a sha512
3.4SM3 字符串(需 easy_gmssl)-i “你好,密码学人 CipherHUB!” -a sm3easy_encryption_tool hash -i "你好,密码学人 CipherHUB!" -a sm3
3.5SHA256 base64 输入-i “5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=” -e -a sha256easy_encryption_tool hash -i "5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=" -e -a sha256
3.6SHA256 文件-i /path/to/file -f -a sha256easy_encryption_tool hash -i /path/to/file -f -a sha256

4. hmac - HMAC 消息验证码

序号能力输入参数完整命令行
4.1HMAC-SHA256 默认 key-i “你好,密码学人 CipherHUB!”easy_encryption_tool hmac -i "你好,密码学人 CipherHUB!"
4.2HMAC-SHA256 指定 key-i “你好,密码学人 CipherHUB!” -k 01234567890123456789012345678901easy_encryption_tool hmac -i "你好,密码学人 CipherHUB!" -k 01234567890123456789012345678901
4.3HMAC-SHA384-i “你好,密码学人 CipherHUB!” -a sha384 -k 01234567890123456789012345678901easy_encryption_tool hmac -i "你好,密码学人 CipherHUB!" -a sha384 -k 01234567890123456789012345678901
4.4HMAC-SHA512-i “你好,密码学人 CipherHUB!” -a sha512 -k 01234567890123456789012345678901easy_encryption_tool hmac -i "你好,密码学人 CipherHUB!" -a sha512 -k 01234567890123456789012345678901
4.5HMAC-SM3(需 easy_gmssl)-i “你好,密码学人 CipherHUB!” -a sm3 -k 01234567890123456789012345678901easy_encryption_tool hmac -i "你好,密码学人 CipherHUB!" -a sm3 -k 01234567890123456789012345678901
4.6HMAC base64 输入-i “5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=” -e -k 01234567890123456789012345678901easy_encryption_tool hmac -i "5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=" -e -k 01234567890123456789012345678901
4.7HMAC 文件-i /path/to/file -f -k 01234567890123456789012345678901easy_encryption_tool hmac -i /path/to/file -f -k 01234567890123456789012345678901

5. aes - AES 对称加解密

5.1 AES-CBC

序号能力输入参数完整命令行
5.1.1CBC 加密字符串-m cbc -a encrypt -i “你好,密码学人 CipherHUB!”easy_encryption_tool aes -m cbc -a encrypt -i "你好,密码学人 CipherHUB!"
5.1.2CBC 加密(指定 key/iv)-m cbc -a encrypt -i “你好,密码学人 CipherHUB!” -k 01234567890123456789012345678901 -v 0123456789012345easy_encryption_tool aes -m cbc -a encrypt -i "你好,密码学人 CipherHUB!" -k 01234567890123456789012345678901 -v 0123456789012345
5.1.3CBC 解密先执行 5.1.2 获取 cipher,再解密easy_encryption_tool aes -m cbc -a decrypt -i "<上一步输出的cipher>" -e -k 01234567890123456789012345678901 -v 0123456789012345
5.1.4CBC 加密 base64 输入-m cbc -a encrypt -i “5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=” -e -k 01234567890123456789012345678901 -v 0123456789012345easy_encryption_tool aes -m cbc -a encrypt -i "5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=" -e -k 01234567890123456789012345678901 -v 0123456789012345
5.1.5CBC 加密文件-m cbc -a encrypt -i /path/to/plain.txt -f -o /tmp/cipher.bin -k 01234567890123456789012345678901 -v 0123456789012345easy_encryption_tool aes -m cbc -a encrypt -i /path/to/plain.txt -f -o /tmp/cipher.bin -k 01234567890123456789012345678901 -v 0123456789012345
5.1.6CBC 解密文件-m cbc -a decrypt -i /tmp/cipher.bin -f -o /tmp/plain.txt -k 01234567890123456789012345678901 -v 0123456789012345easy_encryption_tool aes -m cbc -a decrypt -i /tmp/cipher.bin -f -o /tmp/plain.txt -k 01234567890123456789012345678901 -v 0123456789012345

5.2 AES-GCM

序号能力输入参数完整命令行
5.2.1GCM 加密字符串-m gcm -a encrypt -i “你好,密码学人 CipherHUB!” -k 01234567890123456789012345678901 -v 012345678901234567890123easy_encryption_tool aes -m gcm -a encrypt -i "你好,密码学人 CipherHUB!" -k 01234567890123456789012345678901 -v 012345678901234567890123
5.2.2GCM 解密(需 tag)先执行 5.2.1 获取 cipher 和 auth_tageasy_encryption_tool aes -m gcm -a decrypt -i "<cipher>" -e -t "<auth_tag>" -k 01234567890123456789012345678901 -v 012345678901234567890123
5.2.3GCM 加密文件-m gcm -a encrypt -i /path/to/plain.txt -f -o /tmp/gcm_cipher.bin -k 01234567890123456789012345678901 -v 012345678901234567890123easy_encryption_tool aes -m gcm -a encrypt -i /path/to/plain.txt -f -o /tmp/gcm_cipher.bin -k 01234567890123456789012345678901 -v 012345678901234567890123
5.2.4GCM 解密文件需保存 5.2.3 输出的 auth_tageasy_encryption_tool aes -m gcm -a decrypt -i /tmp/gcm_cipher.bin -f -o /tmp/plain.txt -t "<auth_tag>" -k 01234567890123456789012345678901 -v 012345678901234567890123

6. sm4 - SM4 国密对称加解密(需 easy_gmssl)

6.1 SM4-CBC

序号能力输入参数完整命令行
6.1.1SM4-CBC 加密字符串-m cbc -a encrypt -i “你好,密码学人 CipherHUB!” -k 0123456789012345 -v 0123456789012345easy_encryption_tool sm4 -m cbc -a encrypt -i "你好,密码学人 CipherHUB!" -k 0123456789012345 -v 0123456789012345
6.1.2SM4-CBC 解密先执行 6.1.1 获取 ciphereasy_encryption_tool sm4 -m cbc -a decrypt -i "<cipher>" -e -k 0123456789012345 -v 0123456789012345
6.1.3SM4-CBC 加密文件-m cbc -a encrypt -i /path/to/plain.txt -f -o /tmp/sm4_cipher.bin -k 0123456789012345 -v 0123456789012345easy_encryption_tool sm4 -m cbc -a encrypt -i /path/to/plain.txt -f -o /tmp/sm4_cipher.bin -k 0123456789012345 -v 0123456789012345
6.1.4SM4-CBC 解密文件-m cbc -a decrypt -i /tmp/sm4_cipher.bin -f -o /tmp/plain.txt -k 0123456789012345 -v 0123456789012345easy_encryption_tool sm4 -m cbc -a decrypt -i /tmp/sm4_cipher.bin -f -o /tmp/plain.txt -k 0123456789012345 -v 0123456789012345

6.2 SM4-GCM

序号能力输入参数完整命令行
6.2.1SM4-GCM 加密字符串-m gcm -a encrypt -i “你好,密码学人 CipherHUB!” -k 0123456789012345 -v 012345678901234567890123 –aad “密码学人 CipherHUB 默认 AAD 数据”easy_encryption_tool sm4 -m gcm -a encrypt -i "你好,密码学人 CipherHUB!" -k 0123456789012345 -v 012345678901234567890123 --aad "密码学人 CipherHUB 默认 AAD 数据"
6.2.2SM4-GCM 解密先执行 6.2.1 获取 cipher 和 auth_tageasy_encryption_tool sm4 -m gcm -a decrypt -i "<cipher>" -e -t "<auth_tag>" -k 0123456789012345 -v 012345678901234567890123 --aad "密码学人 CipherHUB 默认 AAD 数据"

7. zuc - ZUC 祖冲之流密码(需 easy_gmssl)

序号能力输入参数完整命令行
7.1ZUC 加密字符串-a encrypt -i “你好,密码学人 CipherHUB!” -k 0123456789012345 -v 0123456789012345easy_encryption_tool zuc -a encrypt -i "你好,密码学人 CipherHUB!" -k 0123456789012345 -v 0123456789012345
7.2ZUC 解密先执行 7.1 获取 ciphereasy_encryption_tool zuc -a decrypt -i "<cipher>" -e -k 0123456789012345 -v 0123456789012345
7.3ZUC 加密文件-a encrypt -i /path/to/plain.txt -f -o /tmp/zuc_cipher.bin -k 0123456789012345 -v 0123456789012345easy_encryption_tool zuc -a encrypt -i /path/to/plain.txt -f -o /tmp/zuc_cipher.bin -k 0123456789012345 -v 0123456789012345
7.4ZUC 解密文件-a decrypt -i /tmp/zuc_cipher.bin -f -o /tmp/plain.txt -k 0123456789012345 -v 0123456789012345easy_encryption_tool zuc -a decrypt -i /tmp/zuc_cipher.bin -f -o /tmp/plain.txt -k 0123456789012345 -v 0123456789012345

8. rsa - RSA 非对称加解密与签名验签

8.1 密钥生成

序号能力输入参数完整命令行
8.1.1生成 2048 位 PEM 密钥对(无密码)-f rsa_testeasy_encryption_tool rsa generate -f rsa_test
8.1.2生成 4096 位 PEM 密钥对(带密码)-f rsa_test -s 4096 -p 1234567890easy_encryption_tool rsa generate -f rsa_test -s 4096 -p 1234567890
8.1.3生成 DER 格式密钥对-f rsa_test -e der -s 2048easy_encryption_tool rsa generate -f rsa_test -e der -s 2048
8.1.4生成随机密码的密钥对-f rsa_test -s 2048 -reasy_encryption_tool rsa generate -f rsa_test -s 2048 -r

8.2 RSA 加解密

序号能力输入参数完整命令行
8.2.1OAEP-SHA256 加密-f rsa_test_rsa_public.pem -i “你好,密码学人 CipherHUB!” -m oaep -h sha256easy_encryption_tool rsa encrypt -f rsa_test_rsa_public.pem -i "你好,密码学人 CipherHUB!" -m oaep -h sha256
8.2.2OAEP-SHA256 解密(无密码私钥)-f rsa_test_rsa_private.pem -i “” -m oaep -h sha256easy_encryption_tool rsa decrypt -f rsa_test_rsa_private.pem -i "<cipher>" -m oaep -h sha256
8.2.3OAEP-SHA256 解密(带密码私钥)-f rsa_test_rsa_private_cipher.pem -i “” -m oaep -h sha256 -p 1234567890easy_encryption_tool rsa decrypt -f rsa_test_rsa_private_cipher.pem -i "<cipher>" -m oaep -h sha256 -p 1234567890
8.2.4OAEP-SHA384 加解密-m oaep -h sha384easy_encryption_tool rsa encrypt -f rsa_test_rsa_public.pem -i "你好,密码学人 CipherHUB!" -m oaep -h sha384
8.2.5OAEP-SHA512 加解密-m oaep -h sha512easy_encryption_tool rsa encrypt -f rsa_test_rsa_public.pem -i "你好,密码学人 CipherHUB!" -m oaep -h sha512
8.2.6PKCS1v15 加解密-m pkcs1v15easy_encryption_tool rsa encrypt -f rsa_test_rsa_public.pem -i "你好,密码学人 CipherHUB!" -m pkcs1v15
8.2.7base64 输入加密-f rsa_test_rsa_public.pem -i “5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=” -c -m oaepeasy_encryption_tool rsa encrypt -f rsa_test_rsa_public.pem -i "5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=" -c -m oaep

8.3 RSA 签名验签

序号能力输入参数完整命令行
8.3.1PSS-SHA256 签名-f rsa_test_rsa_private.pem -i “你好,密码学人 CipherHUB!” -m pss -h sha256easy_encryption_tool rsa sign -f rsa_test_rsa_private.pem -i "你好,密码学人 CipherHUB!" -m pss -h sha256
8.3.2PSS-SHA256 验签-f rsa_test_rsa_public.pem -i “你好,密码学人 CipherHUB!” -m pss -s “easy_encryption_tool rsa verify -f rsa_test_rsa_public.pem -i "你好,密码学人 CipherHUB!" -m pss -s "<signature>"
8.3.3PSS 签名(带密码私钥)-f rsa_test_rsa_private_cipher.pem -i “你好,密码学人 CipherHUB!” -m pss -p 1234567890easy_encryption_tool rsa sign -f rsa_test_rsa_private_cipher.pem -i "你好,密码学人 CipherHUB!" -m pss -p 1234567890
8.3.4PKCS1v15 签名验签-m pkcs1v15easy_encryption_tool rsa sign -f rsa_test_rsa_private.pem -i "你好,密码学人 CipherHUB!" -m pkcs1v15

9. ecc - ECC 椭圆曲线签名验签与密钥交换

9.1 密钥生成

序号能力输入参数完整命令行
9.1.1生成 secp256k1 密钥对-f ecc_testeasy_encryption_tool ecc generate -f ecc_test
9.1.2生成 secp256r1 密钥对-f ecc_test -c secp256r1easy_encryption_tool ecc generate -f ecc_test -c secp256r1
9.1.3生成 secp384r1 带密码-f ecc_test -c secp384r1 -p 1234567890easy_encryption_tool ecc generate -f ecc_test -c secp384r1 -p 1234567890
9.1.4生成 secp521r1 DER 格式-f ecc_test -c secp521r1 -e dereasy_encryption_tool ecc generate -f ecc_test -c secp521r1 -e der

9.2 ECDH 密钥交换

序号能力输入参数完整命令行
9.2.1ECDH 派生共享密钥(alice 视角)需先生成 alice、bob 密钥对easy_encryption_tool ecc ecdh -a alice_ecc_public.pem -k alice_ecc_private_cipher.pem -p 1234567890 -b bob_ecc_public.pem -l 32 -s "密码学人【CipherHUB】" -c "ecc handshake context data"
9.2.2ECDH 派生共享密钥(bob 视角)与 9.2.1 使用相同 salt/contexteasy_encryption_tool ecc ecdh -a bob_ecc_public.pem -k bob_ecc_private_cipher.pem -p 1234567890 -b alice_ecc_public.pem -l 32 -s "密码学人【CipherHUB】" -c "ecc handshake context data"
9.2.3ECDH 指定 hash 和 length-h sha256 -l 64easy_encryption_tool ecc ecdh -a alice_ecc_public.pem -k alice_ecc_private_cipher.pem -p 1234567890 -b bob_ecc_public.pem -l 64 -h sha256 -s "密码学人【CipherHUB】" -c "ecc handshake context data"

9.3 ECC 签名验签

序号能力输入参数完整命令行
9.3.1ECDSA-SHA256 签名-f ecc_test_ecc_private.pem -i “你好,密码学人 CipherHUB!” -h sha256easy_encryption_tool ecc sign -f ecc_test_ecc_private.pem -i "你好,密码学人 CipherHUB!" -h sha256
9.3.2ECDSA-SHA256 验签-f ecc_test_ecc_public.pem -i “你好,密码学人 CipherHUB!” -s “easy_encryption_tool ecc verify -f ecc_test_ecc_public.pem -i "你好,密码学人 CipherHUB!" -s "<signature>"
9.3.3ECDSA-SHA384 签名验签-h sha384easy_encryption_tool ecc sign -f ecc_test_ecc_private.pem -i "你好,密码学人 CipherHUB!" -h sha384
9.3.4ECDSA-SHA512 签名验签-h sha512easy_encryption_tool ecc sign -f ecc_test_ecc_private.pem -i "你好,密码学人 CipherHUB!" -h sha512
9.3.5base64 输入签名-i “5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=” -ceasy_encryption_tool ecc sign -f ecc_test_ecc_private.pem -i "5L2g5aW977yM5a+G56CB5a2m5Lq6IENpcGhlckhVQiE=" -c

10. sm2 - SM2 国密加解密与签名验签(需 easy_gmssl)

10.1 密钥生成

序号能力输入参数完整命令行
10.1.1生成 SM2 密钥对-f sm2_test -p 1234567890easy_encryption_tool sm2 generate -f sm2_test -p 1234567890
10.1.2生成随机密码的 SM2 密钥对-f sm2_test -reasy_encryption_tool sm2 generate -f sm2_test -r

10.2 SM2 加解密

序号能力输入参数完整命令行
10.2.1SM2 加密 C1C3C2_ASN1-f sm2_test_sm2_public.pem -i “你好,密码学人 CipherHUB!” -m C1C3C2_ASN1easy_encryption_tool sm2 encrypt -f sm2_test_sm2_public.pem -i "你好,密码学人 CipherHUB!" -m C1C3C2_ASN1
10.2.2SM2 解密 C1C3C2_ASN1-f sm2_test_sm2_private.pem -i “” -p 1234567890easy_encryption_tool sm2 decrypt -f sm2_test_sm2_private.pem -i "<cipher>" -p 1234567890
10.2.3SM2 加密 C1C3C2-m C1C3C2easy_encryption_tool sm2 encrypt -f sm2_test_sm2_public.pem -i "你好,密码学人 CipherHUB!" -m C1C3C2
10.2.4SM2 加密 C1C2C3_ASN1-m C1C2C3_ASN1easy_encryption_tool sm2 encrypt -f sm2_test_sm2_public.pem -i "你好,密码学人 CipherHUB!" -m C1C2C3_ASN1
10.2.5SM2 加密 hex 输出-o hexeasy_encryption_tool sm2 encrypt -f sm2_test_sm2_public.pem -i "你好,密码学人 CipherHUB!" -o hex
10.2.6SM2 解密 hex 输入-xeasy_encryption_tool sm2 decrypt -f sm2_test_sm2_private.pem -i "<hex_cipher>" -x -p 1234567890

10.3 SM2 签名验签

序号能力输入参数完整命令行
10.3.1SM2 签名 RS_ASN1-f sm2_test_sm2_private.pem -i “你好,密码学人 CipherHUB!” -m RS_ASN1 -p 1234567890easy_encryption_tool sm2 sign -f sm2_test_sm2_private.pem -i "你好,密码学人 CipherHUB!" -m RS_ASN1 -p 1234567890
10.3.2SM2 验签 RS_ASN1-f sm2_test_sm2_public.pem -i “你好,密码学人 CipherHUB!” -s “easy_encryption_tool sm2 verify -f sm2_test_sm2_public.pem -i "你好,密码学人 CipherHUB!" -s "<signature>"
10.3.3SM2 签名 RS 格式-m RSeasy_encryption_tool sm2 sign -f sm2_test_sm2_private.pem -i "你好,密码学人 CipherHUB!" -m RS -p 1234567890
10.3.4SM2 指定 signer_id–signer-id 1234567812345678easy_encryption_tool sm2 sign -f sm2_test_sm2_private.pem -i "你好,密码学人 CipherHUB!" -p 1234567890 --signer-id 1234567812345678

11. cert-parse - 证书解析

序号能力输入参数完整命令行
11.1解析 PEM 格式证书-f /path/to/cert.pem -e pemeasy_encryption_tool cert-parse -f /path/to/cert.pem -e pem
11.2解析 DER 格式证书-f /path/to/cert.der -e dereasy_encryption_tool cert-parse -f /path/to/cert.der -e der
11.3解析证书(详细模式)-f /path/to/cert.pem -e pem -veasy_encryption_tool cert-parse -f /path/to/cert.pem -e pem -v
11.4解析国密 SM2 证书-f /path/to/sm2_cert.pem -e pem -geasy_encryption_tool cert-parse -f /path/to/sm2_cert.pem -e pem -g

附录:测试执行检查清单

执行测试时建议按以下顺序准备测试数据:

  1. 密钥文件:先执行 8.1.1、8.1.2、9.1.1、9.1.3、10.1.1 生成所需密钥
  2. ECC ECDH:需生成 alice、bob 两对密钥
  3. 文件测试:准备测试文件 /path/to/plain.txt,内容可为 你好,密码学人 CipherHUB!
  4. 证书测试:准备 PEM/DER 格式证书文件

比对 CipherHUB 时,请确保:

  • 使用相同的明文、密钥、IV、AAD 等参数
  • 国密算法需在 CipherHUB 和 easy_encryption_tool 均启用
  • SM2 签名验签的 signer_id 需一致(默认 1234567812345678
  • ECC ECDH 的 salt、context 需一致