代码拉取完成,页面将自动刷新
同步操作将从 snowland.ltd/snowland-smx-python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
>>> from pysmx.SM2 import generate_keypair
>>> pk, sk = generate_keypair()
- signature
>>> from pysmx.SM2 import Sign
>>> len_para = 64
>>> sig = Sign("hello", sk, '12345678abcdef', len_para)
- verify
>>> from pysmx.SM2 import Verify
>>> len_para = 64
>>> Verify(sig, "hello", pk, len_para)
- encrpto
>>> from pysmx.SM2 import Encrypt
>>> e = b'hello'
>>> len_para = 64
>>> C = Encrypt(e, pk, len_para, 0) # 0 means var e is not a hex string
- decrpto
>>> from pysmx.SM2 import Decrypt
>>> len_para = 64
>>> m = Decrypt(C, sk, len_para)
>>> from pysmx.SM3 import SM3
>>> sm3 = SM3()
>>> sm3.update('abc')
>>> sm3.hexdigest()
- method 2:
>>> from pysmx.SM3 import hash_msg
>>> s = 'abc'
>>> hash_msg(s)
>>> from pysmx.SM4 import Sm4, ENCRYPT, DECRYPT
>>> key_data = b'hello word errrr...' # 16 bytes at least
>>> sm4 = Sm4()
>>> input_data = [1,2,3]
>>> sm4.sm4_set_key(key_data, ENCRYPT)
>>> msg = sm4.sm4_crypt_ecb()
- decryto
>>> from pysmx.SM4 import Sm4, ENCRYPT, DECRYPT
>>> key_data = b'hello word errrr...' # 16 bytes at least
>>> sm4 = Sm4()
>>> sm4.sm4_set_key(key_data, DECRYPT)
>>> sm4.sm4_crypt_ecb(msg)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。