Chiffrement Java RSA

Je suis en train de coder une simple Chaîne de caractères "test" d'avant en arrière.

public static String encode(Key publicKey, String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {

    byte[] byteData = data.getBytes(); //convert string to byte array

    Cipher cipher = Cipher.getInstance(ALGORITHM); //create conversion processing object
    cipher.init(Cipher.ENCRYPT_MODE, publicKey); //initialize object's mode and key

    byte[] encryptedByteData = cipher.doFinal(byteData); //use object for encryption

    return new String(encryptedByteData); //convert encrypted byte array to string and return it

}

public static String decode(Key privateKey, String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {

    byte[] byteData = data.getBytes(); //convert string to byte array

    Cipher cipher = Cipher.getInstance(ALGORITHM); //create conversion processing object
    cipher.init(Cipher.DECRYPT_MODE, privateKey); //initialize object's mode and key

    System.out.println(byteData.length);

    byte[] decryptedByteData = cipher.doFinal(byteData); //use object for decryption

    return new String(decryptedByteData); //convert decrypted byte array to string and return it

}

Cependant, bien que le cryptage fonctionne très bien (ALGORITHME "RSA"), en essayant de décrypter la chaîne, j'ai juste pris du chiffrement "test", je reçois de l'exception suivante:

javax.crypto.IllegalBlockSizeException: les Données ne doivent pas être de plus de 256 octets

Dois-je diviser les octets chiffrés en blocs de 256 afin d'être capable de le décrypter?

source d'informationauteur arik