Hello,
Well Ive tried everything I know.
I am passing an encrypted encoded url to a java program to have it decrypted decoded.
I am passing only the string of the above mentioned URL.
I have tried many versions of constructors/main methods and such. But, it's rejecting everything with the above error. I have a test program that does the same thing as my JNI only it has a main method to be called from the command line and it works correctly.
Am I defining the constructor correctly to receive the parm?IS my RPG sending the parm correctly
My jni program
My java program
Well Ive tried everything I know.
I am passing an encrypted encoded url to a java program to have it decrypted decoded.
I am passing only the string of the above mentioned URL.
I have tried many versions of constructors/main methods and such. But, it's rejecting everything with the above error. I have a test program that does the same thing as my JNI only it has a main method to be called from the command line and it works correctly.
Am I defining the constructor correctly to receive the parm?IS my RPG sending the parm correctly
My jni program
Code:
D new_AES PR like(AES) D ExtProc(*java: D 'pashaAES': D *CONSTRUCTOR) D AESString like(jString) D decrypt PR like(jString) D extproc(*java: D 'pashaAES': D 'decrypt') D argBytes like(jString) eval xString = new_String(%trim(SCENCODED)) eval AES = new_AES(xString) eval xString = new_String(%trim(SCENCODED)) eval yString = decrypt(AES:xString) // returns java.lang.ArrayStoreException in java program
Code:
public class pashaAES { public pashaAES(String input) throws Exception { } public String decrypt(String input) throws Exception{ String IV = "my secret code"; String Key = "my super secret code"; String input2 = input.trim(); String decodedUrl = URLDecoder.decode(input2, "UTF-8"); byte[] decodedIV = Base64.decodeBase64(IV); byte[] decodedKey = Base64.decodeBase64(Key); byte[] decodedinput = Base64.decodeBase64(decodedUrl); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "IBMJCE"); SecretKeySpec key = new SecretKeySpec(decodedKey, "AES"); cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(decodedIV)); System.out.println("cipher = " + new String(cipher.doFinal(decodedinput),"UTF-8")); return new String(cipher.doFinal(decodedinput),"UTF-8"); } }
Comment