public class RSA extends Object
| Modifier and Type | Field and Description |
|---|---|
static KeyFactory |
RSA_KEY_FACTORY |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decrypt(byte[] bs,
PrivateKey privateKey)
RSA私钥解密
|
static byte[] |
decrypt(byte[] bs,
String privateKey) |
static String |
decrypt(String s,
PrivateKey privateKey) |
static String |
decrypt(String s,
String privateKey) |
static byte[] |
encrypt(byte[] bs,
PublicKey publicKey)
RSA公钥加密
|
static byte[] |
encrypt(byte[] bs,
String publicKey) |
static String |
encrypt(String s,
PublicKey publicKey) |
static String |
encrypt(String s,
String publicKey) |
static Pair<RSAPublicKey,RSAPrivateKey> |
generatorKeys()
随机生成 公私钥对
|
static Pair<RSAPublicKey,RSAPrivateKey> |
generatorKeys(int length)
随机生成 公私钥对
|
static RSAPrivateKey |
getPrivateKey(byte[] key)
RSA pkcs8 私钥 -> RSAPrivateKey
|
static RSAPrivateKey |
getPrivateKey(File file) |
static RSAPrivateKey |
getPrivateKey(String key) |
static RSAPublicKey |
getPublicKey(byte[] key)
RSA 公钥文件 -> getRSAPublicKey
|
static RSAPublicKey |
getPublicKey(File file) |
static RSAPublicKey |
getPublicKey(RSAPrivateKey key)
RSA 私钥文件 -> RSA 公钥文件
|
static RSAPublicKey |
getPublicKey(String key) |
static byte[] |
sign(byte[] bs,
PrivateKey privateKey) |
static byte[] |
sign(byte[] bs,
PrivateKey privateKey,
RSASignature signModel)
RSA私钥签名
|
static byte[] |
sign(byte[] bs,
String privateKey) |
static byte[] |
sign(byte[] bs,
String privateKey,
RSASignature signModel) |
static String |
sign(String s,
PrivateKey privateKey) |
static String |
sign(String s,
PrivateKey privateKey,
RSASignature signModel) |
static String |
sign(String s,
String privateKey) |
static String |
sign(String s,
String privateKey,
RSASignature signModel) |
static boolean |
verify(byte[] bs,
PublicKey publicKey,
byte[] sign) |
static boolean |
verify(byte[] bs,
PublicKey publicKey,
byte[] sign,
RSASignature signModel)
RSA公钥验签
|
static boolean |
verify(byte[] bs,
String publicKey,
byte[] sign) |
static boolean |
verify(byte[] bs,
String publicKey,
byte[] sign,
RSASignature signModel) |
static boolean |
verify(String s,
PublicKey publicKey,
String sign) |
static boolean |
verify(String s,
PublicKey publicKey,
String sign,
RSASignature signModel) |
static boolean |
verify(String s,
String publicKey,
String sign) |
static boolean |
verify(String s,
String publicKey,
String sign,
RSASignature signModel) |
public static final KeyFactory RSA_KEY_FACTORY
public static byte[] encrypt(byte[] bs,
String publicKey)
public static byte[] encrypt(byte[] bs,
PublicKey publicKey)
bs - bytespublicKey - 公钥public static String decrypt(String s, PrivateKey privateKey)
public static byte[] decrypt(byte[] bs,
String privateKey)
public static byte[] decrypt(byte[] bs,
PrivateKey privateKey)
bs - bytesprivateKey - 私钥public static String sign(String s, PrivateKey privateKey)
public static byte[] sign(byte[] bs,
String privateKey)
public static byte[] sign(byte[] bs,
PrivateKey privateKey)
public static String sign(String s, String privateKey, RSASignature signModel)
public static String sign(String s, PrivateKey privateKey, RSASignature signModel)
public static byte[] sign(byte[] bs,
String privateKey,
RSASignature signModel)
public static byte[] sign(byte[] bs,
PrivateKey privateKey,
RSASignature signModel)
bs - bytesprivateKey - 私钥signModel - 签名类型RSASignaturepublic static boolean verify(byte[] bs,
String publicKey,
byte[] sign)
public static boolean verify(byte[] bs,
PublicKey publicKey,
byte[] sign)
public static boolean verify(String s, String publicKey, String sign, RSASignature signModel)
public static boolean verify(String s, PublicKey publicKey, String sign, RSASignature signModel)
public static boolean verify(byte[] bs,
String publicKey,
byte[] sign,
RSASignature signModel)
public static boolean verify(byte[] bs,
PublicKey publicKey,
byte[] sign,
RSASignature signModel)
bs - 明文bytespublicKey - 公钥sign - 签名signModel - 签名类型RSASignaturepublic static RSAPrivateKey getPrivateKey(File file)
public static RSAPrivateKey getPrivateKey(String key)
public static RSAPrivateKey getPrivateKey(byte[] key)
key - 私钥public static RSAPublicKey getPublicKey(File file)
public static RSAPublicKey getPublicKey(String key)
public static RSAPublicKey getPublicKey(byte[] key)
key - 公钥public static RSAPublicKey getPublicKey(RSAPrivateKey key)
key - 私钥public static Pair<RSAPublicKey,RSAPrivateKey> generatorKeys()
public static Pair<RSAPublicKey,RSAPrivateKey> generatorKeys(int length)
length - 512 ~ 16384Copyright © 2025. All rights reserved.