public class SM2 extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
SM2.KeyExchange
密钥协商辅助类
|
static class |
SM2.Signature |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
decrypt(byte[] encryptData,
BigInteger privateKey)
私钥解密
|
byte[] |
encrypt(byte[] inputBuffer,
org.bouncycastle.math.ec.ECPoint publicKey)
公钥加密
|
byte[] |
encrypt(File inputfile,
org.bouncycastle.math.ec.ECPoint publicKey)
公钥加密
|
byte[] |
encrypt(String input,
org.bouncycastle.math.ec.ECPoint publicKey)
公钥加密
* @param input
加密原文
|
void |
exportPrivateKey(BigInteger privateKey,
String path)
导出私钥到本地
|
void |
exportPublicKey(org.bouncycastle.math.ec.ECPoint publicKey,
String path)
导出公钥到本地
|
SM2KeyPair |
generateKeyPair()
生成密钥对
|
BigInteger |
importPrivateKey(String path)
从本地导入私钥
|
org.bouncycastle.math.ec.ECPoint |
importPublicKey(String path)
从本地导入公钥
|
boolean |
isDebug() |
static void |
main(String[] args) |
static void |
printHexString(byte[] b)
以16进制打印字节数组
|
static String |
privateKeyToString(BigInteger privateKey) |
static String |
publicKeyToString(org.bouncycastle.math.ec.ECPoint publicKey) |
void |
setDebug(boolean debug) |
SM2.Signature |
sign(String M,
String IDA,
SM2KeyPair keyPair)
签名
|
static BigInteger |
stringToPrivateKey(String key) |
static org.bouncycastle.math.ec.ECPoint |
stringToPublicKey(String key) |
boolean |
verify(String M,
SM2.Signature signature,
String IDA,
org.bouncycastle.math.ec.ECPoint aPublicKey)
验签
|
public boolean isDebug()
public void setDebug(boolean debug)
public static void printHexString(byte[] b)
b - public byte[] encrypt(String input, org.bouncycastle.math.ec.ECPoint publicKey)
publicKey - 公钥public byte[] encrypt(byte[] inputBuffer,
org.bouncycastle.math.ec.ECPoint publicKey)
inputBuffer - 加密原文publicKey - 公钥public byte[] encrypt(File inputfile, org.bouncycastle.math.ec.ECPoint publicKey) throws Exception
inputfile - 加密原文publicKey - 公钥Exceptionpublic String decrypt(byte[] encryptData, BigInteger privateKey)
encryptData - 密文数据字节数组privateKey - 解密私钥public SM2KeyPair generateKeyPair()
public void exportPublicKey(org.bouncycastle.math.ec.ECPoint publicKey,
String path)
publicKey - path - public static String publicKeyToString(org.bouncycastle.math.ec.ECPoint publicKey)
public static org.bouncycastle.math.ec.ECPoint stringToPublicKey(String key)
public org.bouncycastle.math.ec.ECPoint importPublicKey(String path)
path - public void exportPrivateKey(BigInteger privateKey, String path)
privateKey - path - public static String privateKeyToString(BigInteger privateKey)
public static BigInteger stringToPrivateKey(String key)
public BigInteger importPrivateKey(String path)
path - public SM2.Signature sign(String M, String IDA, SM2KeyPair keyPair)
M - 签名信息IDA - 签名方唯一标识keyPair - 签名方密钥对public boolean verify(String M, SM2.Signature signature, String IDA, org.bouncycastle.math.ec.ECPoint aPublicKey)
M - 签名信息signature - 签名IDA - 签名方唯一标识aPublicKey - 签名方公钥public static void main(String[] args) throws UnsupportedEncodingException
Copyright © 2024. All rights reserved.