私はJAVAを使っています 私の友人はSYMBIANを使っています
私と私の友人は同じ RSA モジュラスを持っています。公開鍵を使用してデータを暗号化すると、友人は同じものを復号化できます。しかし、友人が公開鍵でデータを暗号化すると、データを復号化できません。「データはゼロで開始する必要があります」というエラーが表示されました
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));
}
ありがとうスニル