1 Star 0 Fork 26

BLZ / snowland-smx-python

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
BSD-3-Clause

snowland-smx-python

  1. SM2
    gm signature a. generate keypair
>>> from pysmx.SM2 import generate_keypair
>>> pk, sk = generate_keypair()
  1. signature
>>> from pysmx.SM2 import Sign
>>> len_para = 64
>>> sig = Sign("hello", sk, '12345678abcdef', len_para)
  1. verify
>>> from pysmx.SM2 import Verify
>>> len_para = 64
>>> Verify(sig, "hello", pk, len_para)
  1. 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
  1. decrpto
>>> from  pysmx.SM2 import Decrypt
>>> len_para = 64
>>> m = Decrypt(C, sk, len_para)
  1. SM3
    hash a. method 1:
>>> from pysmx.SM3 import SM3
>>> sm3 = SM3()
>>> sm3.update('abc')
>>> sm3.hexdigest()
  1. method 2:
>>> from pysmx.SM3 import hash_msg
>>> s = 'abc'
>>> hash_msg(s)
  1. 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()
  1. 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)
  1. ZUC
    waiting for update
BSD 3-Clause License Copyright (c) 2018, AAFun All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

国密算法SM2,SM3,SM4,ZUC expand collapse
Python
BSD-3-Clause
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Python
1
https://gitee.com/joo2019/snowland-smx-python.git
git@gitee.com:joo2019/snowland-smx-python.git
joo2019
snowland-smx-python
snowland-smx-python
master

Search