public class RSA extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
RSA.RSAKeyPair |
| 构造器和说明 |
|---|
RSA() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
decrypt(PrivateKey key,
byte[] encodedText)
解密
|
static String |
decrypt(PrivateKey key,
String encodedText) |
static byte[] |
encrypt(PublicKey key,
byte[] plainBytes)
加密
|
static String |
encrypt(PublicKey key,
String plainText) |
static RSA.RSAKeyPair |
generateKeyPair(int keySize)
生成RSA密匙对
|
static String[] |
generateKeyStrPair(int keySize)
生成RSA密匙对
|
static RSAPrivateKey |
getPrivateKey(String privateKey)
生成私钥
|
static RSAPublicKey |
getPublicKey(String publicKey) |
static PrivateKey |
loadPrivateKey(File file)
从文件中加载私钥
|
static PrivateKey |
loadPrivateKey(InputStream in)
从文件中加载私钥
|
static PrivateKey |
loadPrivateKey(String priKeyString) |
static PrivateKey |
loadPrivateKeyFromKeyStore(KeyStore keyStore,
String alias,
String keyPass)
从KeyStore获取私钥
|
static PrivateKey |
loadPrivateKeyFromKeyStore(String location,
String alias,
String storeType,
String storePass,
String keyPass)
从KeyStore获取私钥
|
static PublicKey |
loadPublicKey(byte[] keyBytes)
还原公钥,X509EncodedKeySpec 用于构建公钥的规范
|
static PublicKey |
loadPublicKey(File file)
从文件加载公钥
|
static PublicKey |
loadPublicKey(InputStream in)
从文件中输入流中加载公钥
|
static PublicKey |
loadPublicKey(String pubKeyString) |
static PublicKey |
loadPublicKeyFromCert(String certPath)
从证书文件获取公钥
|
static PublicKey |
loadPublicKeyFromKeyStore(KeyStore keyStore,
String alias,
String keyPass) |
static PublicKey |
loadPublicKeyFromKeyStore(String location,
String alias,
String storeType,
String storePass,
String keyPass)
从KeyStore获取公钥
|
static void |
main(String[] args) |
static String |
privateDecrypt(String data,
RSAPrivateKey privateKey)
私钥解密
|
static String |
publicEncrypt(String data,
RSAPublicKey publicKey) |
public static RSA.RSAKeyPair generateKeyPair(int keySize)
keySize - public static String[] generateKeyStrPair(int keySize)
keySize - public static PublicKey loadPublicKey(InputStream in)
in - 公钥输入流public static PrivateKey loadPrivateKey(File file)
file - 私钥文件public static PrivateKey loadPrivateKey(InputStream in)
keyFileName - 私钥文件名public static PrivateKey loadPrivateKey(String priKeyString)
public static PublicKey loadPublicKey(byte[] keyBytes)
keyBytes - public static PrivateKey loadPrivateKeyFromKeyStore(String location, String alias, String storeType, String storePass, String keyPass)
location - alias - storeType - storePass - keyPass - public static PrivateKey loadPrivateKeyFromKeyStore(KeyStore keyStore, String alias, String keyPass)
location - alias - keyStore - storePass - keyPass - public static PublicKey loadPublicKeyFromKeyStore(String location, String alias, String storeType, String storePass, String keyPass)
location - alias - storeType - storePass - keyPass - public static PublicKey loadPublicKeyFromKeyStore(KeyStore keyStore, String alias, String keyPass)
keyStore - alias - keyPass - public static PublicKey loadPublicKeyFromCert(String certPath) throws CertificateException, FileNotFoundException
certPath - CertificateExceptionFileNotFoundExceptionpublic static byte[] encrypt(PublicKey key, byte[] plainBytes)
key - plainBytes - public static String decrypt(PrivateKey key, byte[] encodedText)
key - encodedText - public static String decrypt(PrivateKey key, String encodedText)
public static String privateDecrypt(String data, RSAPrivateKey privateKey)
data - privateKey - public static String publicEncrypt(String data, RSAPublicKey publicKey)
public static RSAPrivateKey getPrivateKey(String privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException
privateKey - NoSuchAlgorithmExceptionInvalidKeySpecExceptionpublic static RSAPublicKey getPublicKey(String publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException
Copyright © 2025. All rights reserved.