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.
2 Answers
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.
Comments
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"); 2 Comments
President James K. Polk
No, don't do that. Never use the no-args
String.getBytes() for applications like this. Always specify a Charset, and almost always you can use UTF-8. Also the SecretKeySpec class is not available on J2ME.Andy Mikula
What's available on J2ME? I can remove this answer, but I don't want to lose your comment.