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

Tércio Costa

Uma simples solução seria fazer 3 vezes o join na tabela  flp_documentos, uma vez para cada um dos tipos de documentos citados, e assim você retornaria cada um desses elementos no seu select list.

1 - 1
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,098 views