@IocBean public class RSAUtil extends Object
| 构造器和说明 |
|---|
RSAUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte |
asc_to_bcd(byte asc) |
static byte[] |
ASCII_To_BCD(byte[] ascii,
int asc_len)
ASCII码转BCD码
|
static String |
bcd2Str(byte[] bytes)
BCD转字符串
|
static String |
decryptByPrivateKey(String data,
RSAPrivateKey privateKey)
私钥解密
|
static String |
encryptByPublicKey(String data,
RSAPublicKey publicKey)
公钥加密
|
static HashMap<String,Object> |
getKeys()
生成公钥和私钥
|
static RSAPrivateKey |
getPrivateKey(String modulus,
String exponent)
使用模和指数生成RSA私钥
/None/NoPadding
|
static RSAPublicKey |
getPublicKey(String modulus,
String exponent)
使用模和指数生成RSA公钥
|
static byte[][] |
splitArray(byte[] data,
int len)
拆分数组
|
static String[] |
splitString(String string,
int len)
拆分字符串
|
public static HashMap<String,Object> getKeys() throws NoSuchAlgorithmException
public static RSAPublicKey getPublicKey(String modulus, String exponent)
modulus - 模exponent - 指数public static RSAPrivateKey getPrivateKey(String modulus, String exponent)
modulus - 模exponent - 指数public static String encryptByPublicKey(String data, RSAPublicKey publicKey) throws Exception
data - publicKey - Exceptionpublic static String decryptByPrivateKey(String data, RSAPrivateKey privateKey) throws Exception
data - privateKey - Exceptionpublic static byte[] ASCII_To_BCD(byte[] ascii,
int asc_len)
public static byte asc_to_bcd(byte asc)
public static String bcd2Str(byte[] bytes)
public static byte[][] splitArray(byte[] data,
int len)
Copyright © 2018. All rights reserved.