Hello everybody,

I'm developing my program and I need to send over network encrypted data. I can do this but when I call method responsible for decrypting I receive null. It seems that there's something missing in my code and I don't know what.Let me show you my code:

public String decrypt(String text) {
        try {
            encrypted = new sun.misc.BASE64Decoder().decodeBuffer(text);
            this.text = decrypter.doFinal(encrypted);
            return new String(this.text, "UTF8");
        } catch (javax.crypto.BadPaddingException e) {
        } catch (IllegalBlockSizeException e) {
        } catch (UnsupportedEncodingException e) {
        } catch (java.io.IOException e) {
        return null;
6 Years
Discussion Span
Last Post by JamesCherrill

What's missing in your code is all the e.printStackTrace(); statements in your catch blocks. Right now you could be getting any of those exceptions and you won't know.
As a general rule you should NEVER have an empty catch in a new program unless you are very sure why you want to ignore that exception.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.