0
현재 BadPaddingException 오류가 발생했습니다. 암호화 된 데이터를 클라이언트에서 서버로 보내고 있습니다. 서버는 수신 된 데이터에 대해 해독을 수행합니다.
누구든지 코드를 살펴보고 오류를 지적하는 데 도움이 될 수 있습니까?BadPaddingException RSA 암호화/암호 해독 오류
클라이언트 측
try{
Cipher c = Cipher.getInstance("RSA");
c.init(Cipher.ENCRYPT_MODE, servPubKey);
String myMessage = "this is a secret message";
byte[] msgByte = myMessage.getBytes();
ObjectOutputStream outVehicle3 = new ObjectOutputStream(socket.getOutputStream());
ParamClass print4 = new ParamClass (cipherText);
outVehicle3.writeObject(print4);
} catch (Throwable e) {
// TODO Auto-generated catch block
tv.append("\nUnable to perform RSA encryption!");
e.printStackTrace();
}
서버 측
ObjectInputStream inServ3 = new ObjectInputStream(socket.getInputStream());
try{
ParamClass print5 = (ParamClass) (inServ3.readObject());
Cipher dec = Cipher.getInstance("RSA");
dec.init(Cipher.DECRYPT_MODE, serverPrivateKey);
byte[] dectyptedText = dec.doFinal(print5.cipherText);
String decipherText = dectyptedText.toString();
System.out.println("\nDecrypted Message to string: " + decipherText);
}catch (Throwable e) {
e.printStackTrace();
System.out.println("Unable to perform RSA decryption!");
}
는 에러가 다음 라인 occoured했다.
byte[] dectyptedText = dec.doFinal(print5.cipherText);
귀하의 도움과 안내에 미리 감사드립니다.