public class Sm2Utils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected GmCryptoNativeUtil |
gmCryptoNativeUtil |
| 构造器和说明 |
|---|
Sm2Utils() |
Sm2Utils(CipherMode cipherMode) |
| 限定符和类型 | 方法和说明 |
|---|---|
byte[] |
decryptASN1ToData(byte[] prvKeyBytes,
byte[] cipherBytes)
解密为字节码(ASN1-DER密文编码模式)
|
String |
decryptASN1ToHex(String prvKeyHex,
String cipherHex)
解密为16进制串(ASN1-DER密文编码模式)
|
String |
decryptASN1ToText(String prvKeyHex,
String cipherHex)
解密为字符串(ASN1-DER密文编码模式)
|
byte[] |
decryptToData(byte[] prvKeyBytes,
byte[] cipherBytes)
解密为字节码(字符串拼接模式)
|
String |
decryptToHex(String prvKeyHex,
String cipherHex)
解密为16进制串(字符串拼接模式)
|
String |
decryptToText(String prvKeyHex,
String cipherHex)
解密为字符串(字符串拼接模式)
|
byte[] |
encryptASN1FromData(byte[] pubKeyBytes,
byte[] sourceBytes)
字节码加密(ASN1-DER密文编码模式)
|
String |
encryptASN1FromHex(String pubKeyHex,
String sourceHex)
16进制串加密(ASN1-DER密文编码模式)
|
String |
encryptASN1FromText(String pubKeyHex,
String sourceText)
字符串加密(ASN1-DER编码模式)
|
byte[] |
encryptFromData(byte[] pubKeyBytes,
byte[] sourceBytes)
字节码加密(字符串拼接模式)
|
String |
encryptFromHex(String pubKeyHex,
String sourceHex)
16进制串加密(字符串拼接模式)
|
String |
encryptFromText(String pubKeyHex,
String sourceText)
字符串加密(字符串拼接模式)
|
String[] |
generateKeyPair()
产生SM2公私钥对
|
String |
getPublicKey(String prvKeyHex) |
byte[] |
signASN1FromData(byte[] prvKeyBytes,
byte[] sourceBytes)
字节码签名(ASN1-DER签名编码模式)
|
String |
signASN1FromHex(String prvKeyHex,
String sourceHex)
16进制串签名(ASN1-DER签名编码模式)
|
String |
signASN1FromText(String prvKeyHex,
String sourceText)
字符串签名(ASN1-DER签名编码模式)
|
byte[] |
signFromData(byte[] prvKeyBytes,
byte[] sourceBytes)
字节码签名
|
String |
signFromHex(String prvKeyHex,
String sourceHex)
16进制串签名
|
String |
signFromText(String prvKeyHex,
String sourceText)
字符串签名
|
boolean |
verifySignASN1FromData(byte[] pubKeyBytes,
byte[] sourceBytes,
byte[] signBytes)
字节码验签(ASN1-DER签名编码模式)
|
boolean |
verifySignASN1FromHex(String pubKeyHex,
String sourceHex,
String signHex)
16进制串验签(ASN1-DER签名编码模式)
|
boolean |
verifySignASN1FromText(String pubKeyHex,
String sourceText,
String signHex)
字符串验签(ASN1-DER签名编码模式)
|
boolean |
verifySignFromData(byte[] pubKeyBytes,
byte[] sourceBytes,
byte[] signBytes)
字节码验签
|
boolean |
verifySignFromHex(String pubKeyHex,
String sourceHex,
String signHex)
16进制串验签
|
boolean |
verifySignFromText(String pubKeyHex,
String sourceText,
String signHex)
字符串验签
|
protected final GmCryptoNativeUtil gmCryptoNativeUtil
public Sm2Utils()
public Sm2Utils(CipherMode cipherMode)
cipherMode - 密文格式:C1C2C3,C1C3C2public String[] generateKeyPair()
public String encryptFromText(String pubKeyHex, String sourceText) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceText - 字符串明文GmCryptoExceptionpublic String encryptFromHex(String pubKeyHex, String sourceHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceHex - 16进制串明文GmCryptoExceptionpublic byte[] encryptFromData(byte[] pubKeyBytes,
byte[] sourceBytes)
throws GmCryptoException
pubKeyBytes - 字节码公钥sourceBytes - 字节码明文GmCryptoExceptionpublic String decryptToText(String prvKeyHex, String cipherHex) throws GmCryptoException
prvKeyHex - 16进制串私钥cipherHex - 16进制串密文GmCryptoExceptionpublic String decryptToHex(String prvKeyHex, String cipherHex) throws GmCryptoException
prvKeyHex - 16进制串私钥cipherHex - 16进制串密文GmCryptoExceptionpublic byte[] decryptToData(byte[] prvKeyBytes,
byte[] cipherBytes)
throws GmCryptoException
prvKeyBytes - 字节码私钥cipherBytes - 字节码密文GmCryptoExceptionpublic String encryptASN1FromText(String pubKeyHex, String sourceText) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceText - 字符串明文GmCryptoExceptionpublic String encryptASN1FromHex(String pubKeyHex, String sourceHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceHex - 16进制串明文GmCryptoExceptionpublic byte[] encryptASN1FromData(byte[] pubKeyBytes,
byte[] sourceBytes)
throws GmCryptoException
pubKeyBytes - 字节码公钥sourceBytes - 字节码明文GmCryptoExceptionpublic String decryptASN1ToText(String prvKeyHex, String cipherHex) throws GmCryptoException
prvKeyHex - 16进制串私钥cipherHex - 16进制串密文GmCryptoExceptionpublic String decryptASN1ToHex(String prvKeyHex, String cipherHex) throws GmCryptoException
prvKeyHex - 16进制串私钥cipherHex - 16进制串密文GmCryptoExceptionpublic byte[] decryptASN1ToData(byte[] prvKeyBytes,
byte[] cipherBytes)
throws GmCryptoException
prvKeyBytes - 字节码私钥cipherBytes - 字节码密文GmCryptoExceptionpublic String signFromText(String prvKeyHex, String sourceText) throws GmCryptoException
prvKeyHex - 16进制串私钥sourceText - 字符串明文GmCryptoExceptionpublic String signFromHex(String prvKeyHex, String sourceHex) throws GmCryptoException
prvKeyHex - 16进制串私钥sourceHex - 16进制串明文GmCryptoExceptionpublic byte[] signFromData(byte[] prvKeyBytes,
byte[] sourceBytes)
throws GmCryptoException
prvKeyBytes - 字节码私钥sourceBytes - 字节码明文GmCryptoExceptionpublic boolean verifySignFromText(String pubKeyHex, String sourceText, String signHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceText - 字符串明文signHex - 16进制串签名GmCryptoExceptionpublic boolean verifySignFromHex(String pubKeyHex, String sourceHex, String signHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceHex - 16进制串明文signHex - 16进制串签名GmCryptoExceptionpublic boolean verifySignFromData(byte[] pubKeyBytes,
byte[] sourceBytes,
byte[] signBytes)
throws GmCryptoException
pubKeyBytes - 字节码公钥sourceBytes - 字节码明文signBytes - 字节码签名GmCryptoExceptionpublic String signASN1FromText(String prvKeyHex, String sourceText) throws GmCryptoException
prvKeyHex - 16进制串私钥sourceText - 字符串明文GmCryptoExceptionpublic String signASN1FromHex(String prvKeyHex, String sourceHex) throws GmCryptoException
prvKeyHex - 16进制串私钥sourceHex - 16进制串明文GmCryptoExceptionpublic byte[] signASN1FromData(byte[] prvKeyBytes,
byte[] sourceBytes)
throws GmCryptoException
prvKeyBytes - 字节码私钥sourceBytes - 字节码明文GmCryptoExceptionpublic boolean verifySignASN1FromText(String pubKeyHex, String sourceText, String signHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceText - 字符串明文signHex - 16进制串签名GmCryptoExceptionpublic boolean verifySignASN1FromHex(String pubKeyHex, String sourceHex, String signHex) throws GmCryptoException
pubKeyHex - 16进制串公钥sourceHex - 16进制串明文signHex - 16进制串签名GmCryptoExceptionpublic boolean verifySignASN1FromData(byte[] pubKeyBytes,
byte[] sourceBytes,
byte[] signBytes)
throws GmCryptoException
pubKeyBytes - 字节码公钥sourceBytes - 字节码明文signBytes - 字节码签名GmCryptoExceptionCopyright © 2025. All rights reserved.