# EasyGmssl-Python
## 一、概述
EasyGmSSL FORK 自<u>**北京大学 GUNAZHI 老师团队的开源国密算法库**</u>: [GmSSL](https://github.com/guanzhi/GmSSL),EasyGmSSL旨在为开发者提供一套接口更加友好的国密算法应用开发工具。它涵盖了SM2、SM3、SM4等国密算法的核心功能,并针对实际使用场景中的痛点进行了针对性改进。
此 SDK 的 git 地址为:https://github.com/bowenerchen/GmSSL-Python
更详细的示例代码请参考:https://github.com/bowenerchen/GmSSL-Python/tree/main/demo_easy_gmssl
## 二、特色功能
1. **便捷安装**
- 在通过pip安装本SDK时,具备自动编译底层C库的能力,并且会智能地安装编译好的二进制文件,避免对系统路径造成污染,确保了安装过程的简洁性与独立性,让您无需繁琐的手动配置即可快速上手。
2. **SM2增强功能**
- **密钥加解密模式多样化**
新增了多种SM2密钥加解密模式选择,包括C1C3C2、C1C3C2_ASN1、C1C2C3、C1C2C3_ASN1。这些模式为不同应用需求提供了更灵活的加密策略,无论是在对加密效率有要求,还是对加密数据格式兼容性有考量的场景下,都能找到合适的解决方案。
- **签名验签模式扩展**
在SM2签名验签时,增加了RS_ASN1、RS两种模式选择,适应不同的签名规范和验证场景,使签名验签操作更加贴合实际业务需求。
- **密钥读取便捷化**
允许用户轻松读取SM2公钥、私钥的十六进制明文,方便在调试、密钥管理等环节快速获取关键信息,提升开发效率。
3. **基础算法优化**
对于SM4和SM3以及随机数生成部分,虽然核心算法基于底层库,但在接口层着重增加了参数说明。这使得即使是初次接触国密算法的开发者,也能迅速理解每个参数的含义与用途,降低了开发门槛,加速项目开发进程。
## 三、安装指南
只需在命令行中执行以下pip命令即可完成安装:
```bash
pip install easy_gmssl
```
安装过程中,系统会自动处理底层C库的编译与安装事宜,待编译安装完成后即可开启国密算法开发之旅。
## 四、使用示例
1. **SM2密钥加解密**
- 输出多种模式下的密文:
```python
from __future__ import annotations
from easy_gmssl import EasySm2EncryptionKey, SM2CipherFormat, SM2CipherMode
enc = EasySm2EncryptionKey()
plain = 'hello,world'
# 遍历当前支持的所有 SM2 加解密算法模式
# 当前支持的模式包括:
# C1C3C2_ASN1、C1C3C2、C1C2C3_ASN1、C1C2C3
for mode in SM2CipherMode:
print(mode, '密文 in Hex:', enc.Encrypt('hello,world'.encode('utf-8'), mode, SM2CipherFormat.HexStr))
```
2. **SM2公钥、私钥读取**
```python
from __future__ import annotations
from easy_gmssl import EasySm2Key
test = EasySm2Key()
print('公钥数据 In Hex:', test.get_sm2_public_key_in_hex())
print('私钥数据 In Hex:', test.get_sm2_private_key_in_hex())
```
3. **SM2签名验签**
- 以RS_ASN1模式为例:
```python
from __future__ import annotations
import random
from easy_gmssl import EasySM2SignKey, EasySM2VerifyKey, SignatureMode
signer_id = 'test_signer'
print('signer_id hex:', signer_id.encode('utf-8').hex())
# 初始化用于签名验签的 SM2 密钥,此时不需要关心签名值的模式
test = EasySM2SignKey(signer_id = signer_id, pem_private_key_file = './test_keys/tmp_test_sm2_private.pem',
password = '123456')
plain = bytes([random.randint(0, 255) for _ in range(0, 64)])
print('plain hex:', plain.hex())
print('private key hex:', test.get_sm2_private_key_in_hex())
print('public key hex:', test.get_sm2_public_key_in_hex())
# 计算签名
test.UpdateData(plain)
# 指定签名值模式为 RS 模式,可选 RS、RS_ASN1
sign_value = test.GetSignValue(signature_mode = SignatureMode.RS)
print('signature hex:', sign_value.hex())
# 初始化用于验证签名的 SM2 密钥
verify_test = EasySM2VerifyKey(signer_id = signer_id, pem_public_key_file = './test_keys/tmp_test_sm2_public.pem')
# 验证签名
verify_test.UpdateData(plain)
# 验证签名时同样指定签名值格式为 RS 模式
ret = verify_test.VerifySignature(sign_value, signature_mode = SignatureMode.RS)
```
4. **SM4对称加解密示例**
```python
from __future__ import annotations
from easy_gmssl import EasySm4CBC
from gmssl import SM4_BLOCK_SIZE, SM4_CBC_IV_SIZE
key = 'x' * SM4_BLOCK_SIZE
iv = 'y' * SM4_CBC_IV_SIZE
test_cbc_enc = EasySm4CBC(key.encode('utf-8'), iv.encode('utf-8'), True)
plain1 = 'hello,world'
plain2 = '1234567890'
cipher1 = test_cbc_enc.Update(plain1.encode('utf-8'))
cipher2 = test_cbc_enc.Update(plain2.encode('utf-8'))
ciphers = cipher1 + cipher2 + test_cbc_enc.Finish()
test_dec = EasySm4CBC(key.encode('utf-8'), iv.encode('utf-8'), False)
decrypted_plain1 = test_dec.Update(ciphers)
decrypted_plain = decrypted_plain1 + test_dec.Finish()
print('解密成功:', decrypted_plain == (plain1 + plain2).encode('utf-8'))
```
5. **SM3 HASH 与 HMAC 示例**
```python
from __future__ import annotations
import random
from easy_gmssl import EasySM3Digest, EasySM3Hmac
from easy_gmssl.gmssl import SM3_HMAC_MAX_KEY_SIZE
test = EasySM3Digest()
plain1 = 'hello,world'.encode('utf-8')
plain2 = '1234567890'.encode('utf-8')
plain3 = (plain1 + plain2)
print('plain hex:', plain3.hex())
test.UpdateData(plain3)
hash_value_2, hash_len, length2 = test.GetHash()
print('hash value:', hash_value_2.hex())
print('hash value length in bytes:', hash_len)
plain = 'hello,world'.encode('utf-8')
print('plain hex:', plain.hex())
key = bytes([random.randint(0, 255) for _ in range(0, SM3_HMAC_MAX_KEY_SIZE)])
print('key hex:', key.hex())
test = EasySM3Hmac(key)
test.UpdateData(plain)
hmac_hex, hmac_len, plain_len = test.GetHmac()
print('hmac value:', hmac_hex.hex(), 'hmac len:', hmac_len, 'plain len:', plain_len)
```
6. **随机数生成示例**
```python
from __future__ import annotations
from easy_gmssl import EasyRandomData, RandomMode
test = EasyRandomData()
ret = test.GetRandomData(20)
print(ret.hex())
test = EasyRandomData(mode = RandomMode.RandomStr)
ret = test.GetRandomData(64)
print(ret)
```
7. **ZUC 加解密示例**
```python
from __future__ import annotations
from easy_gmssl import EasyRandomData, EasyZuc
from easy_gmssl.gmssl import ZUC_IV_SIZE, ZUC_KEY_SIZE
# 生成密钥与 IV
key = EasyRandomData().GetRandomData(ZUC_KEY_SIZE)
iv = EasyRandomData().GetRandomData(ZUC_IV_SIZE)
# 加密操作
test = EasyZuc(key, iv)
plain1 = 'hello,world'.encode('utf-8')
cipher1 = test.Update(plain1)
plain2 = '1234567890'.encode('utf-8')
cipher2 = test.Update(plain2)
cipher3 = test.Finish()
# 解密操作
test2 = EasyZuc(key, iv)
ret1 = test2.Update(cipher1)
ret2 = test2.Update(cipher2)
ret3 = test2.Update(cipher3)
ret4 = test2.Finish()
assert ret1 + ret2 + ret3 + ret4 == plain1 + plain2
print('解密成功:', ret1 + ret2 + ret3 + ret4 == plain1 + plain2)
```
## 五、注意事项
1. 在使用SM2密钥加解密、签名验签等功能时,请务必根据实际需求谨慎选择合适的模式,不同模式在数据格式、兼容性等方面存在差异。
2. 对于读取的公钥、私钥十六进制明文,要妥善保管,防止泄露,因为这是加密体系的核心机密信息。
3. 虽然SDK尽力优化了接口,但国密算法涉及密码学专业知识,在开发高安全性应用时,建议开发者深入了解相关算法原理,确保应用的安全性。
Raw data
{
"_id": null,
"home_page": "https://cloud.tencent.com/developer/user/1371154/articles",
"name": "easy-gmssl",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "bowenerchen",
"author_email": "bowenerchen@foxmail.com",
"download_url": "https://files.pythonhosted.org/packages/5f/9c/be65b4f9fee185e2c7c7cb4d80a03ba6f717c7e7529af632430a49a92fda/easy_gmssl-1.2.0.tar.gz",
"platform": null,
"description": "# EasyGmssl-Python\n\n## \u4e00\u3001\u6982\u8ff0\n\nEasyGmSSL FORK \u81ea<u>**\u5317\u4eac\u5927\u5b66 GUNAZHI \u8001\u5e08\u56e2\u961f\u7684\u5f00\u6e90\u56fd\u5bc6\u7b97\u6cd5\u5e93**</u>\uff1a [GmSSL](https://github.com/guanzhi/GmSSL)\uff0cEasyGmSSL\u65e8\u5728\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e00\u5957\u63a5\u53e3\u66f4\u52a0\u53cb\u597d\u7684\u56fd\u5bc6\u7b97\u6cd5\u5e94\u7528\u5f00\u53d1\u5de5\u5177\u3002\u5b83\u6db5\u76d6\u4e86SM2\u3001SM3\u3001SM4\u7b49\u56fd\u5bc6\u7b97\u6cd5\u7684\u6838\u5fc3\u529f\u80fd\uff0c\u5e76\u9488\u5bf9\u5b9e\u9645\u4f7f\u7528\u573a\u666f\u4e2d\u7684\u75db\u70b9\u8fdb\u884c\u4e86\u9488\u5bf9\u6027\u6539\u8fdb\u3002\n\n\u6b64 SDK \u7684 git \u5730\u5740\u4e3a\uff1ahttps://github.com/bowenerchen/GmSSL-Python\n\n\u66f4\u8be6\u7ec6\u7684\u793a\u4f8b\u4ee3\u7801\u8bf7\u53c2\u8003\uff1ahttps://github.com/bowenerchen/GmSSL-Python/tree/main/demo_easy_gmssl\n\n## \u4e8c\u3001\u7279\u8272\u529f\u80fd\n\n1. **\u4fbf\u6377\u5b89\u88c5**\n - \u5728\u901a\u8fc7pip\u5b89\u88c5\u672cSDK\u65f6\uff0c\u5177\u5907\u81ea\u52a8\u7f16\u8bd1\u5e95\u5c42C\u5e93\u7684\u80fd\u529b\uff0c\u5e76\u4e14\u4f1a\u667a\u80fd\u5730\u5b89\u88c5\u7f16\u8bd1\u597d\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u907f\u514d\u5bf9\u7cfb\u7edf\u8def\u5f84\u9020\u6210\u6c61\u67d3\uff0c\u786e\u4fdd\u4e86\u5b89\u88c5\u8fc7\u7a0b\u7684\u7b80\u6d01\u6027\u4e0e\u72ec\u7acb\u6027\uff0c\u8ba9\u60a8\u65e0\u9700\u7e41\u7410\u7684\u624b\u52a8\u914d\u7f6e\u5373\u53ef\u5feb\u901f\u4e0a\u624b\u3002\n \n2. **SM2\u589e\u5f3a\u529f\u80fd**\n - **\u5bc6\u94a5\u52a0\u89e3\u5bc6\u6a21\u5f0f\u591a\u6837\u5316**\n \u65b0\u589e\u4e86\u591a\u79cdSM2\u5bc6\u94a5\u52a0\u89e3\u5bc6\u6a21\u5f0f\u9009\u62e9\uff0c\u5305\u62ecC1C3C2\u3001C1C3C2_ASN1\u3001C1C2C3\u3001C1C2C3_ASN1\u3002\u8fd9\u4e9b\u6a21\u5f0f\u4e3a\u4e0d\u540c\u5e94\u7528\u9700\u6c42\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u52a0\u5bc6\u7b56\u7565\uff0c\u65e0\u8bba\u662f\u5728\u5bf9\u52a0\u5bc6\u6548\u7387\u6709\u8981\u6c42\uff0c\u8fd8\u662f\u5bf9\u52a0\u5bc6\u6570\u636e\u683c\u5f0f\u517c\u5bb9\u6027\u6709\u8003\u91cf\u7684\u573a\u666f\u4e0b\uff0c\u90fd\u80fd\u627e\u5230\u5408\u9002\u7684\u89e3\u51b3\u65b9\u6848\u3002\n \n - **\u7b7e\u540d\u9a8c\u7b7e\u6a21\u5f0f\u6269\u5c55**\n \u5728SM2\u7b7e\u540d\u9a8c\u7b7e\u65f6\uff0c\u589e\u52a0\u4e86RS_ASN1\u3001RS\u4e24\u79cd\u6a21\u5f0f\u9009\u62e9\uff0c\u9002\u5e94\u4e0d\u540c\u7684\u7b7e\u540d\u89c4\u8303\u548c\u9a8c\u8bc1\u573a\u666f\uff0c\u4f7f\u7b7e\u540d\u9a8c\u7b7e\u64cd\u4f5c\u66f4\u52a0\u8d34\u5408\u5b9e\u9645\u4e1a\u52a1\u9700\u6c42\u3002\n \n - **\u5bc6\u94a5\u8bfb\u53d6\u4fbf\u6377\u5316**\n \u5141\u8bb8\u7528\u6237\u8f7b\u677e\u8bfb\u53d6SM2\u516c\u94a5\u3001\u79c1\u94a5\u7684\u5341\u516d\u8fdb\u5236\u660e\u6587\uff0c\u65b9\u4fbf\u5728\u8c03\u8bd5\u3001\u5bc6\u94a5\u7ba1\u7406\u7b49\u73af\u8282\u5feb\u901f\u83b7\u53d6\u5173\u952e\u4fe1\u606f\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387\u3002\n \n3. **\u57fa\u7840\u7b97\u6cd5\u4f18\u5316**\n \n \u5bf9\u4e8eSM4\u548cSM3\u4ee5\u53ca\u968f\u673a\u6570\u751f\u6210\u90e8\u5206\uff0c\u867d\u7136\u6838\u5fc3\u7b97\u6cd5\u57fa\u4e8e\u5e95\u5c42\u5e93\uff0c\u4f46\u5728\u63a5\u53e3\u5c42\u7740\u91cd\u589e\u52a0\u4e86\u53c2\u6570\u8bf4\u660e\u3002\u8fd9\u4f7f\u5f97\u5373\u4f7f\u662f\u521d\u6b21\u63a5\u89e6\u56fd\u5bc6\u7b97\u6cd5\u7684\u5f00\u53d1\u8005\uff0c\u4e5f\u80fd\u8fc5\u901f\u7406\u89e3\u6bcf\u4e2a\u53c2\u6570\u7684\u542b\u4e49\u4e0e\u7528\u9014\uff0c\u964d\u4f4e\u4e86\u5f00\u53d1\u95e8\u69db\uff0c\u52a0\u901f\u9879\u76ee\u5f00\u53d1\u8fdb\u7a0b\u3002\n\n## \u4e09\u3001\u5b89\u88c5\u6307\u5357\n\n\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c\u4ee5\u4e0bpip\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u5b89\u88c5\uff1a\n\n```bash\npip install easy_gmssl\n```\n\n\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5904\u7406\u5e95\u5c42C\u5e93\u7684\u7f16\u8bd1\u4e0e\u5b89\u88c5\u4e8b\u5b9c\uff0c\u5f85\u7f16\u8bd1\u5b89\u88c5\u5b8c\u6210\u540e\u5373\u53ef\u5f00\u542f\u56fd\u5bc6\u7b97\u6cd5\u5f00\u53d1\u4e4b\u65c5\u3002\n\n## \u56db\u3001\u4f7f\u7528\u793a\u4f8b\n\n1. **SM2\u5bc6\u94a5\u52a0\u89e3\u5bc6**\n - \u8f93\u51fa\u591a\u79cd\u6a21\u5f0f\u4e0b\u7684\u5bc6\u6587\uff1a\n ```python\n from __future__ import annotations\n \n from easy_gmssl import EasySm2EncryptionKey, SM2CipherFormat, SM2CipherMode\n \n enc = EasySm2EncryptionKey()\n plain = 'hello,world'\n # \u904d\u5386\u5f53\u524d\u652f\u6301\u7684\u6240\u6709 SM2 \u52a0\u89e3\u5bc6\u7b97\u6cd5\u6a21\u5f0f\n # \u5f53\u524d\u652f\u6301\u7684\u6a21\u5f0f\u5305\u62ec\uff1a\n # C1C3C2_ASN1\u3001C1C3C2\u3001C1C2C3_ASN1\u3001C1C2C3\n for mode in SM2CipherMode:\n print(mode, '\u5bc6\u6587 in Hex:', enc.Encrypt('hello,world'.encode('utf-8'), mode, SM2CipherFormat.HexStr))\n ```\n\n2. **SM2\u516c\u94a5\u3001\u79c1\u94a5\u8bfb\u53d6**\n ```python\n from __future__ import annotations\n \n from easy_gmssl import EasySm2Key\n \n test = EasySm2Key()\n print('\u516c\u94a5\u6570\u636e In Hex:', test.get_sm2_public_key_in_hex())\n print('\u79c1\u94a5\u6570\u636e In Hex:', test.get_sm2_private_key_in_hex())\n ```\n\n3. **SM2\u7b7e\u540d\u9a8c\u7b7e**\n\n - \u4ee5RS_ASN1\u6a21\u5f0f\u4e3a\u4f8b\uff1a\n ```python\n from __future__ import annotations\n \n import random\n \n from easy_gmssl import EasySM2SignKey, EasySM2VerifyKey, SignatureMode\n \n signer_id = 'test_signer'\n print('signer_id hex:', signer_id.encode('utf-8').hex())\n # \u521d\u59cb\u5316\u7528\u4e8e\u7b7e\u540d\u9a8c\u7b7e\u7684 SM2 \u5bc6\u94a5\uff0c\u6b64\u65f6\u4e0d\u9700\u8981\u5173\u5fc3\u7b7e\u540d\u503c\u7684\u6a21\u5f0f\n test = EasySM2SignKey(signer_id = signer_id, pem_private_key_file = './test_keys/tmp_test_sm2_private.pem',\n password = '123456')\n plain = bytes([random.randint(0, 255) for _ in range(0, 64)])\n print('plain hex:', plain.hex())\n print('private key hex:', test.get_sm2_private_key_in_hex())\n print('public key hex:', test.get_sm2_public_key_in_hex())\n \n # \u8ba1\u7b97\u7b7e\u540d\n test.UpdateData(plain)\n # \u6307\u5b9a\u7b7e\u540d\u503c\u6a21\u5f0f\u4e3a RS \u6a21\u5f0f\uff0c\u53ef\u9009 RS\u3001RS_ASN1\n sign_value = test.GetSignValue(signature_mode = SignatureMode.RS)\n print('signature hex:', sign_value.hex())\n \n # \u521d\u59cb\u5316\u7528\u4e8e\u9a8c\u8bc1\u7b7e\u540d\u7684 SM2 \u5bc6\u94a5\n verify_test = EasySM2VerifyKey(signer_id = signer_id, pem_public_key_file = './test_keys/tmp_test_sm2_public.pem')\n # \u9a8c\u8bc1\u7b7e\u540d\n verify_test.UpdateData(plain)\n # \u9a8c\u8bc1\u7b7e\u540d\u65f6\u540c\u6837\u6307\u5b9a\u7b7e\u540d\u503c\u683c\u5f0f\u4e3a RS \u6a21\u5f0f\n ret = verify_test.VerifySignature(sign_value, signature_mode = SignatureMode.RS)\n ```\n\n4. **SM4\u5bf9\u79f0\u52a0\u89e3\u5bc6\u793a\u4f8b**\n\n ```python\n from __future__ import annotations\n \n from easy_gmssl import EasySm4CBC\n from gmssl import SM4_BLOCK_SIZE, SM4_CBC_IV_SIZE\n \n key = 'x' * SM4_BLOCK_SIZE\n iv = 'y' * SM4_CBC_IV_SIZE\n \n test_cbc_enc = EasySm4CBC(key.encode('utf-8'), iv.encode('utf-8'), True)\n plain1 = 'hello,world'\n plain2 = '1234567890'\n cipher1 = test_cbc_enc.Update(plain1.encode('utf-8'))\n cipher2 = test_cbc_enc.Update(plain2.encode('utf-8'))\n ciphers = cipher1 + cipher2 + test_cbc_enc.Finish()\n \n test_dec = EasySm4CBC(key.encode('utf-8'), iv.encode('utf-8'), False)\n decrypted_plain1 = test_dec.Update(ciphers)\n decrypted_plain = decrypted_plain1 + test_dec.Finish()\n \n print('\u89e3\u5bc6\u6210\u529f\uff1a', decrypted_plain == (plain1 + plain2).encode('utf-8'))\n ```\n\n5. **SM3 HASH \u4e0e HMAC \u793a\u4f8b**\n\n ```python\n from __future__ import annotations\n \n import random\n \n from easy_gmssl import EasySM3Digest, EasySM3Hmac\n from easy_gmssl.gmssl import SM3_HMAC_MAX_KEY_SIZE\n \n test = EasySM3Digest()\n \n plain1 = 'hello,world'.encode('utf-8')\n plain2 = '1234567890'.encode('utf-8')\n plain3 = (plain1 + plain2)\n print('plain hex:', plain3.hex())\n test.UpdateData(plain3)\n hash_value_2, hash_len, length2 = test.GetHash()\n print('hash value:', hash_value_2.hex())\n print('hash value length in bytes:', hash_len)\n \n \n plain = 'hello,world'.encode('utf-8')\n print('plain hex:', plain.hex())\n key = bytes([random.randint(0, 255) for _ in range(0, SM3_HMAC_MAX_KEY_SIZE)])\n print('key hex:', key.hex())\n test = EasySM3Hmac(key)\n test.UpdateData(plain)\n hmac_hex, hmac_len, plain_len = test.GetHmac()\n print('hmac value:', hmac_hex.hex(), 'hmac len:', hmac_len, 'plain len:', plain_len)\n ```\n\n6. **\u968f\u673a\u6570\u751f\u6210\u793a\u4f8b**\n\n ```python\n from __future__ import annotations\n from easy_gmssl import EasyRandomData, RandomMode\n test = EasyRandomData()\n ret = test.GetRandomData(20)\n print(ret.hex())\n test = EasyRandomData(mode = RandomMode.RandomStr)\n ret = test.GetRandomData(64)\n print(ret)\n ```\n\n \n\n7. **ZUC \u52a0\u89e3\u5bc6\u793a\u4f8b**\n\n ```python\n from __future__ import annotations\n \n from easy_gmssl import EasyRandomData, EasyZuc\n from easy_gmssl.gmssl import ZUC_IV_SIZE, ZUC_KEY_SIZE\n \n # \u751f\u6210\u5bc6\u94a5\u4e0e IV\n key = EasyRandomData().GetRandomData(ZUC_KEY_SIZE)\n iv = EasyRandomData().GetRandomData(ZUC_IV_SIZE)\n # \u52a0\u5bc6\u64cd\u4f5c\n test = EasyZuc(key, iv)\n plain1 = 'hello,world'.encode('utf-8')\n cipher1 = test.Update(plain1)\n plain2 = '1234567890'.encode('utf-8')\n cipher2 = test.Update(plain2)\n cipher3 = test.Finish()\n \n # \u89e3\u5bc6\u64cd\u4f5c\n test2 = EasyZuc(key, iv)\n ret1 = test2.Update(cipher1)\n ret2 = test2.Update(cipher2)\n ret3 = test2.Update(cipher3)\n ret4 = test2.Finish()\n assert ret1 + ret2 + ret3 + ret4 == plain1 + plain2\n print('\u89e3\u5bc6\u6210\u529f\uff1a', ret1 + ret2 + ret3 + ret4 == plain1 + plain2)\n ```\n\n \n\n## \u4e94\u3001\u6ce8\u610f\u4e8b\u9879\n\n1. \u5728\u4f7f\u7528SM2\u5bc6\u94a5\u52a0\u89e3\u5bc6\u3001\u7b7e\u540d\u9a8c\u7b7e\u7b49\u529f\u80fd\u65f6\uff0c\u8bf7\u52a1\u5fc5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c28\u614e\u9009\u62e9\u5408\u9002\u7684\u6a21\u5f0f\uff0c\u4e0d\u540c\u6a21\u5f0f\u5728\u6570\u636e\u683c\u5f0f\u3001\u517c\u5bb9\u6027\u7b49\u65b9\u9762\u5b58\u5728\u5dee\u5f02\u3002\n2. \u5bf9\u4e8e\u8bfb\u53d6\u7684\u516c\u94a5\u3001\u79c1\u94a5\u5341\u516d\u8fdb\u5236\u660e\u6587\uff0c\u8981\u59a5\u5584\u4fdd\u7ba1\uff0c\u9632\u6b62\u6cc4\u9732\uff0c\u56e0\u4e3a\u8fd9\u662f\u52a0\u5bc6\u4f53\u7cfb\u7684\u6838\u5fc3\u673a\u5bc6\u4fe1\u606f\u3002\n3. \u867d\u7136SDK\u5c3d\u529b\u4f18\u5316\u4e86\u63a5\u53e3\uff0c\u4f46\u56fd\u5bc6\u7b97\u6cd5\u6d89\u53ca\u5bc6\u7801\u5b66\u4e13\u4e1a\u77e5\u8bc6\uff0c\u5728\u5f00\u53d1\u9ad8\u5b89\u5168\u6027\u5e94\u7528\u65f6\uff0c\u5efa\u8bae\u5f00\u53d1\u8005\u6df1\u5165\u4e86\u89e3\u76f8\u5173\u7b97\u6cd5\u539f\u7406\uff0c\u786e\u4fdd\u5e94\u7528\u7684\u5b89\u5168\u6027\u3002\n",
"bugtrack_url": null,
"license": null,
"summary": "easy gmssl for python",
"version": "1.2.0",
"project_urls": {
"Homepage": "https://cloud.tencent.com/developer/user/1371154/articles"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "486072dc43d778b8eead08143576772733b7664c037b2c28c18949b2ebf01df9",
"md5": "118b119d55866ebcf9aa554c177b8f56",
"sha256": "9eb1bd1b6856c61437c02e8bb32a9aaeb4887b4fd8042de957c1fd75c5d2832b"
},
"downloads": -1,
"filename": "easy_gmssl-1.2.0-cp312-cp312-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "118b119d55866ebcf9aa554c177b8f56",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 26467,
"upload_time": "2024-12-24T03:37:31",
"upload_time_iso_8601": "2024-12-24T03:37:31.096772Z",
"url": "https://files.pythonhosted.org/packages/48/60/72dc43d778b8eead08143576772733b7664c037b2c28c18949b2ebf01df9/easy_gmssl-1.2.0-cp312-cp312-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5f9cbe65b4f9fee185e2c7c7cb4d80a03ba6f717c7e7529af632430a49a92fda",
"md5": "7880211532a9f7edde80420fbb278bde",
"sha256": "7b116367b4ce1f87dafc19039e763a1aff9012602dd35163c3aa98df6ea518ff"
},
"downloads": -1,
"filename": "easy_gmssl-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "7880211532a9f7edde80420fbb278bde",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 627669,
"upload_time": "2024-12-24T03:37:34",
"upload_time_iso_8601": "2024-12-24T03:37:34.528594Z",
"url": "https://files.pythonhosted.org/packages/5f/9c/be65b4f9fee185e2c7c7cb4d80a03ba6f717c7e7529af632430a49a92fda/easy_gmssl-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-24 03:37:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "easy-gmssl"
}