急求援助。RSA解密后的结果错误
public byte[] decryptCkey(byte[] text, PrivateKey privatekey) {
byte[] decrypted = null;
try {
// get an RSA cipher object and print the provider
final Cipher cipher = Cipher.getInstance("RSA");
// decrypt the text using the private key
cipher.init(Cipher.DECRYPT_MODE, privatekey);
decrypted = cipher.doFinal(text);
} catch (Exception ex) {
ex.printStackTrace();
}
//System.out.println("Text: " + new String(text));
System.out.println(decrypted.length);
System.out.println(privatekey.getAlgorithm());
return decrypted;
该程序出错部分是,产生一个128bit通信秘钥,存入一个16byte的数组里面, 用客户的公钥加密,然后将密钥发送给客户端。
客户接受到通信密钥后,用客户的私钥解密。
这部分是解密的的代码。
我这边测试时候发现, 解密后的密钥一直就只有10位。
求分析诊断~~
通宵等解答