import java.security.Key;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.Cipher;
import sun.misc.BASE64Decoder;
public String decrypt(){
Map keyMap= new HashMap(4);
String decryptModeCode = null;
Cipher cipher = null;
BASE64Decoder decoder = new BASE64Decoder();
try {
cipher = javax.crypto.Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, (Key) keyMap.get("RSAPrivateKey"));
decryptModeCode = new String(cipher.doFinal(decoder.decodeBuffer("中文")),"gb2312");
System.out.println("decryptModeCode is : " + decryptModeCode );
} catch (Exception e) {
e.printStackTrace();
}
return decryptModeCode;
}
問題自己搞定了,大意了,靜下心來想想就行!