Balasubramaniam Muthusamy wrote:Here is my sample java code and output as below. In the encrypted output I should not have any special character. It should have only alphanumeric.
When you use Base64 encoding, as you are doing, you will not get only alphanumeric characters (i.e. characters in the ranges A-Z, a-z and 0-9); you might also get characters like '='. If you don't want that, then use some other encoding algorithm instead of Base64, that only produces alphanumeric characters.
Note also that catching exceptions and doing nothing with them, as you do in lines 59 - 60, is a bad idea. If an exception happens, you'll never know.
Also, it's not a good idea to use internal Sun classes, such as sun.misc.BASE64Encoder and sun.misc.BASE64Decoder. These classes are not part of Java's public API and they might not exist on all JVM implementations, or they might not even exist in a future version of Oracle's JVM implementation. If you do need to use Base64 encoding, then use a third-party library with a supported API instead, for example
Apache Commons Codec.