/**
* 获取
RSA加密信息
* @param info
* @return
*/
public static String get
RSAInfo(String dataStr){
byte[] en = encrypt(dataStr);
String info = Base64.encode(en);
try {
info = URLEncoder.encode(info,”UTF-8″);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return info;
}
public static byte[] encrypt(String info) {
try {
byte[] modulusBytes = Base64.decode(“yrEAJvQfhhoZcWMzsQw0LZd2OqOTMgOzVl7Ja2w6R1rF+tl+V+6T08zvZAhWye2omdZ8JccefDQNkYTqIcNXu9XqYMTl79FaFVt32wykCIHnvfN8IafVnQKcuWpWDuCbZAocoBisT6LWugyiXWe7cr+2qFSW4nL5YIQ4jxXJn8U=”);
byte[] exponentBytes = Base64.decode(“AQAB”);
BigInteger modulus = new BigInteger(1, modulusBytes);
BigInteger exponent = new BigInteger(1, exponentBytes);
RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(modulus, exponent);
KeyFactory fact = KeyFactory.getInstance(“RSA”);
PublicKey pubKey = fact.generatePublic(rsaPubKey);
Cipher cipher = Cipher.getInstance(“RSA”);
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
byte[] cipherData = cipher.doFinal(new String(info).getBytes());
return cipherData;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}