public class RSAEncrypt extends Object
| 构造器和说明 |
|---|
RSAEncrypt() |
| 限定符和类型 | 方法和说明 |
|---|---|
static RSAPrivateKey |
getPrivateKey(String privateKeyStr)
从字符串中加载私钥
|
static RSAPublicKey |
getPublicKey(String publicKeyStr)
从字符串中加载公钥
|
static byte[] |
privateDecrypt(RSAPrivateKey privateKey,
byte[] cipherData)
私钥解密过程
|
static byte[] |
privateEncrypt(RSAPrivateKey privateKey,
String plainTextData)
私钥加密过程
|
static byte[] |
publicDecrypt(RSAPublicKey publicKey,
byte[] cipherData)
公钥解密过程
|
static byte[] |
publicEncrypt(RSAPublicKey publicKey,
String plainTextData)
公钥加密
|
static byte[] |
sign(byte[] data,
RSAPrivateKey privateKey)
rsa签名
|
static boolean |
verify(byte[] content,
byte[] sign,
RSAPublicKey publicKey)
rsa验签
|
public static RSAPublicKey getPublicKey(String publicKeyStr)
publicKeyStr - 公钥字符串IllegalArgumentException - 公钥格式非法public static RSAPrivateKey getPrivateKey(String privateKeyStr)
privateKeyStr - 私钥数据字符串IllegalArgumentException - 私钥格式非法public static byte[] publicEncrypt(RSAPublicKey publicKey, String plainTextData) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException
publicKey - 公钥plainTextData - 明文数据InvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingExceptionpublic static byte[] privateEncrypt(RSAPrivateKey privateKey, String plainTextData) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException
privateKey - 私钥plainTextData - 明文数据InvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingExceptionpublic static byte[] privateDecrypt(RSAPrivateKey privateKey, byte[] cipherData) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException
privateKey - 私钥cipherData - 密文数据InvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingExceptionpublic static byte[] publicDecrypt(RSAPublicKey publicKey, byte[] cipherData) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException
publicKey - 公钥cipherData - 密文数据InvalidKeyExceptionIllegalBlockSizeExceptionBadPaddingExceptionpublic static byte[] sign(byte[] data,
RSAPrivateKey privateKey)
throws InvalidKeyException,
SignatureException
data - 原始数据privateKey - 私钥InvalidKeyExceptionSignatureExceptionpublic static boolean verify(byte[] content,
byte[] sign,
RSAPublicKey publicKey)
throws InvalidKeyException,
SignatureException
content - 数据sign - 数据签名publicKey - 公钥InvalidKeyExceptionSignatureExceptionCopyright © 2020. All rights reserved.