Python implementation gm algorithm
Project description
- SM2
gm signature a. generate keypair
>>> 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)
- SM3
hash a. method 1:
>>> 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)
- SM4
block encrpto a. encrpto
>>> 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)
- ZUC
waiting for update
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snowland_smx-0.3.1-py3-none-any.whl.
File metadata
- Download URL: snowland_smx-0.3.1-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5901b92305d7e23c08aed244c012e6c8afc5217e5fb47a0fd66489daa4f6f09a
|
|
| MD5 |
0cd35e4659385b124e1266ab11860fdc
|
|
| BLAKE2b-256 |
2c61f59f01d18b2f305473d6f62550bf668610936f34dc908daf25b1a9237846
|