public class RSA extends Object
| 构造器和说明 |
|---|
RSA() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decodePri(byte[] decodeStr)
RSA私钥解密
默认密钥
|
static String |
decodePri(byte[] decodeStr,
String privateKey)
RSA私钥解密
|
static String |
decodePri(String decodeStr)
RSA私钥解密
默认密钥
|
static String |
decodePri(String decodeStr,
String privateKey)
RSA私钥解密
|
static String |
decodePub(byte[] encodeStr)
RSA公钥解密
默认密钥
|
static String |
decodePub(byte[] encodeStr,
String publicKey)
RSA公钥解密
|
static String |
decodePub(String encodeStr)
RSA公钥解密
默认密钥
|
static String |
decodePub(String encodeStr,
String publicKey)
RSA公钥解密
|
static String |
encodePri(byte[] decodeStr)
RSA私钥加密
默认密钥
|
static String |
encodePri(byte[] decodeStr,
String privateKey)
RSA私钥加密
|
static String |
encodePri(String decodeStr)
RSA私钥加密
默认密钥
|
static String |
encodePri(String decodeStr,
String privateKey)
RSA私钥加密
|
static String |
encodePub(byte[] encodeStr)
RSA公钥加密
默认密钥
|
static String |
encodePub(byte[] encodeStr,
String publicKey)
RSA公钥加密
|
static String |
encodePub(String encodeStr)
RSA公钥加密
默认密钥
|
static String |
encodePub(String encodeStr,
String publicKey)
RSA公钥加密
|
static GenerateKeyPair |
generateKey()
生成密钥对
2048默认密钥位数
|
static GenerateKeyPair |
generateKey1024()
生成密钥对
|
Integer |
getKeyLength(PrivateKey privateKey)
获取密钥加密长度
默认加密长度2048
-1表示读取密钥失败
|
Integer |
getKeyLength(PublicKey publicKey)
获取密钥加密长度
默认加密长度2048
-1表示读取密钥失败
|
static GenerateKeyPair |
getKeyPair()
获取密钥信息
|
static String |
getPrivateKey()
获取密钥
密钥单例维护,每次部署全局唯一 重启服务更换密钥
|
Integer |
getPrivateKeyLength(String privateKey)
获取密钥加密长度
默认加密长度2048
-1表示读取密钥失败
|
static String |
getPublicKey()
获取密钥
密钥单例维护,每次部署全局唯一 重启服务更换密钥
|
Integer |
getPublicKeyLength(String publicKey)
获取密钥加密长度
默认加密长度2048
-1表示读取密钥失败
|
GenerateKeyPair |
loadKeyPair(String privateKey,
String publicKey)
加载密钥信息
|
PrivateKey |
loadPrivateKey(String privateKey)
加载密钥信息
|
PublicKey |
loadPublicKey(String publicKey)
加载密钥信息
|
static String |
sign(String data,
String privateKey)
RSA私钥签名
|
static boolean |
verify(String source,
String publicKey,
String sign)
RSA公钥验签
|
public static String encodePub(String encodeStr) throws MsToolsException
encodeStr - 需要加密的字符串MsToolsExceptionpublic static String encodePub(byte[] encodeStr) throws MsToolsException
encodeStr - 需要加密的字节数组MsToolsExceptionpublic static String encodePub(String encodeStr, String publicKey) throws MsToolsException
encodeStr - 需要加密的字符串publicKey - 公钥MsToolsExceptionpublic static String encodePub(byte[] encodeStr, String publicKey) throws MsToolsException
encodeStr - 需要加密的字节数组publicKey - 公钥MsToolsExceptionpublic static String encodePri(String decodeStr) throws MsToolsException
decodeStr - 密文MsToolsExceptionpublic static String encodePri(byte[] decodeStr) throws MsToolsException
decodeStr - 密文字节数组MsToolsExceptionpublic static String encodePri(String decodeStr, String privateKey) throws MsToolsException
decodeStr - 密文privateKey - 私钥MsToolsExceptionpublic static String encodePri(byte[] decodeStr, String privateKey) throws MsToolsException
decodeStr - 密文字节数组privateKey - 私钥MsToolsExceptionpublic static String decodePri(String decodeStr) throws MsToolsException
decodeStr - 密文MsToolsExceptionpublic static String decodePri(byte[] decodeStr) throws MsToolsException
decodeStr - 密文字节数组MsToolsExceptionpublic static String decodePri(String decodeStr, String privateKey) throws MsToolsException
decodeStr - 密文privateKey - 私钥MsToolsExceptionpublic static String decodePri(byte[] decodeStr, String privateKey) throws MsToolsException
decodeStr - 密文字节数组privateKey - 私钥MsToolsExceptionpublic static String decodePub(String encodeStr) throws MsToolsException
encodeStr - 需要加密的字符串MsToolsExceptionpublic static String decodePub(byte[] encodeStr) throws MsToolsException
encodeStr - 需要加密的字节数组MsToolsException - 异常public static String decodePub(String encodeStr, String publicKey) throws MsToolsException
encodeStr - 需要加密的字符串publicKey - 公钥MsToolsException - 异常public static String decodePub(byte[] encodeStr, String publicKey) throws MsToolsException
encodeStr - 需要加密的字节数组publicKey - 公钥MsToolsException - 异常public static GenerateKeyPair generateKey()
public static GenerateKeyPair generateKey1024() throws MsToolsException
MsToolsException - 异常public static String sign(String data, String privateKey) throws MsToolsException
data - 待签名数据privateKey - 私钥MsToolsException - 签名异常public static boolean verify(String source, String publicKey, String sign) throws MsToolsException
source - 原始字符串publicKey - 公钥sign - 签名字符串MsToolsException - 验证异常public static String getPublicKey()
public static String getPrivateKey()
public static GenerateKeyPair getKeyPair()
public PrivateKey loadPrivateKey(String privateKey) throws MsToolsException
privateKey - 私钥MsToolsException - 读取异常public PublicKey loadPublicKey(String publicKey) throws MsToolsException
publicKey - 公钥MsToolsException - 读取异常public GenerateKeyPair loadKeyPair(String privateKey, String publicKey) throws MsToolsException
privateKey - 私钥publicKey - 公钥MsToolsException - 工具public Integer getPublicKeyLength(String publicKey)
publicKey - 密钥public Integer getKeyLength(PublicKey publicKey)
publicKey - 密钥public Integer getPrivateKeyLength(String privateKey)
privateKey - 密钥public Integer getKeyLength(PrivateKey privateKey)
privateKey - 密钥Copyright © 2024. All rights reserved.