Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Decrypting string in AES

Lorenzo AvoledoOct 15 2014 — edited Oct 21 2014

I have to decrypt in java a string crypted in AES 256 from a c# class.

I know the init vector and the passphrase, both are 32 bytes string.

I made a try with this code:

byte [] iv = "1234567812345678".getBytes("UTF-8");

byte [] keyBytes = "1234567812345678".getBytes("UTF-8");

SecretKey aesKey = new SecretKeySpec(keyBytes, "AES");

Cipher cipher = Cipher.getInstance("AES/CBC/NOPADDING");

cipher.init(Cipher.DECRYPT_MODE, aesKey, new IvParameterSpec(iv));

byte[] result = cipher.doFinal(cipherBytes);

But when i put iv and keyBytes of 32 bytes i get this error

Exception in thread "main" java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long

  at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)

  at com.sun.crypto.provider.AESCipher.engineInit(DashoA12275)

  at javax.crypto.Cipher.a(DashoA12275)

  at javax.crypto.Cipher.a(DashoA12275)

  at javax.crypto.Cipher.init(DashoA12275)

  at javax.crypto.Cipher.init(DashoA12275)

Can anyone help me?

Thank you

Lorenzo

Comments

Sven W.

I didn't test it, but I think you could use sub folders. Like /ords/apex/images/i182 and /ords/apex/images/i201
Then map the /i/ path to the base folder /ords/apex/images.

And make sure the image prefix is set to /i/i182/ in one apex application/workspace and to /i/i202/ in the other one.

You can set the image prefix path in shared components/user interfaces

pastedImage_0.png

jariola
Answer

Sven W. wrote:

You can set the image prefix path in shared components/user interfaces

Problem with that is APEX builder might not work properly, because that is application setting.

There have been similar discussion before. Here is one link

Marked as Answer by Fernando Lima · Sep 27 2020
Fernando Lima

Sorry, but this solution is only for application static files.

Thanks.

AndyH

You can change the image prefix for the APEX instance using the reset_image_prefix.sql script.

When installing differing APEX versions in an environment that might use a common web server it's usual to specify the image prefix to be version specific e.g. here we have a PDB per APEX version, so when we install we will make the image prefix specific to that version e.g. /i504/, /i191/, etc.

As long as the image prefix for the APEX instance points to the correct files, all should be well.

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 18 2014
Added on Oct 15 2014
1 comment
2,102 views