Skip to main content

problem with j2me crypto class

1 reply [Last post]
Joined: 2009-06-30
Points: 0

Hi all... below decryption code is work on java sdk. but when i try on j2me, the error come out said that cannot find symbol constructor SecretKeySpec and IvParameterSpec. does anyone has a clue on this problem? please help... thanks a lot.

import javax.crypto.*;

byte[] raw = ciphertext. getBytes();
Cipher ciphertype = Cipher.getInstance("AES/CBC");
SecretKeySpec keySpec = new SecretKeySpec(raw, "AES");
IvParameterSpec ivSpec = new IvParameterSpec("7g^1m)3h4%czl*v1".getBytes());
ciphertype.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
byte[] outText = ciphertype.doFinal(hexToBytes("f1936fe02eed7bb472311e58e6de9677"));

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-15
Points: 0

JavaME MIDP2.0 does not have the javax.crypto package by default.
What tool are you using WTK, or an IDE with some mobile plugin?

make sure you select to have the SATSA jars included then all so add
the import javax.crypto.spec.*; to your imports.