를 사용하여 데이터를 해독하기 위해 나와 내 친구가 같은 RSA 계수가 심비안는 어떻게 자바를 사용하고 내 친구의 RSA의 PrivateKey
를 사용합니다. 공개 키를 사용하여 데이터를 암호화하면 내 친구가 동일한 키를 해독 할 수 있습니다. 하지만 내 친구가 공개 키로 데이터를 암호화하면 데이터를 해독 할 수 없습니다. 나는 "데이터가 0으로 시작해야합니다"
public static byte[] encrypt(byte[] encrptdByte) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
byte[] encryptionByte = null;
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
encryptionByte = cipher.doFinal(encrptdByte);
return encryptionByte;
}
public static void decrypt(byte[] encrptdByte) throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException {
byte[] encryptionByte = null;
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, publicKey);
encryptionByte = cipher.doFinal(encrptdByte);
System.out.println("Recovered String ::: " + new String(encryptionByte));
}
감사 선일과 같은 오류가 발생했습니다
사용중인 Java 코드 중 일부 또는 어떤 라이브러리를 게시 할 수 있습니까? – Thilo
암호화 모드가없는 패딩없이 RSA를 사용하고 있습니다. – Sunil
나는 그것을 보아주세요. – Sunil