The X

SM2 Algorithm Encryption and Decryption

SM2 (ShangMi2) is an elliptic curve cryptographic algorithm. The key generally appears in the HEX string format, but also in the PEM format. In order to facilitate interface processing, this tool will automatically convert Hex format keys to PEM format keys (sm2p256v1). If you need to restore or export the public key from the private key, you can use the ASN.1 tool to parse the PEM key. When using SM2 encryption or decryption, please pay attention to the order of the ciphertext, which is the difference between C1||C2||C3 and C1||C3||C2. C3 is a digest of coordinates and plaintext. Usually the SM3 algorithm is used. Of course, it can also be replaced with other algorithms. As long as the encryption and decryption agreements are unified. KeyId refers to the MD5 (16bits) digest value of the X coordinate of the public key. If the identity of the public and private keys is the same, it can be considered as a paired key. This tool has not been fully tested. If there are errors, please give feedback.