Question

Hi All I want to convert the string (taken as input from user) into a secretkey.I am coding in J2ME.The algorithm used is blowfish.

Was it helpful?

Solution

The Java cryptography APIs are not available in Java ME.

You'll need to download the Bouncy Castle lightweight cryptography API, which supports Java ME. You can then extract the classes you need from there. I found a code example here that should help you get started.

About charsets: Java ME does indeed support UTF-8, so that's always a safe bet. And a good idea, yes, although you'll see a lot of code that doesn't specify a charset.

OTHER TIPS

Edit: Please see Eric's answer. This is not available in J2ME.

To convert a string to a key, you can do:

String strkey = "My key goes here";
SecretKeySpec key = new SecretKeySpec(strkey.getBytes("UTF-8"), "Blowfish");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top