You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Prathyusha Kanala <kn...@gmail.com> on 2015/04/06 20:19:05 UTC

org.apache.commons.codec.binary.Base64 question

Hi,

My web application was initially running on tomcat 7.0.53 and I
use org.apache.commons.codec.binary.Base64 for encryption and decryption.

Now the server has been updated to tomcat 7.0.57 and I get a java
Nullpointer error at c.doFinal line:

    public static String make(String Data) throws Exception {
    byte[] encodedCommons;
        Key key = generateMakeKey();
        Cipher c = Cipher.getInstance(ALGO);
        c.init(Cipher.ENCRYPT_MODE, key);
       * byte[] encVal = c.doFinal(Data.getBytes());*
        encodedCommons = Base64.encodeBase64(encVal);
        String encryptedValue = new String(encodedCommons);
        //BASE64Encoder benc = new BASE64Encoder();
        //String encryptedValue = benc.encode(encVal);
        return encryptedValue;
    }

Is the problem because I need to be using something other than the
org.apache.commons.codec.binary.Base64?

Please advise.

Regards.
Prathyusha

Re: org.apache.commons.codec.binary.Base64 question

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Prathyusha,

On 4/6/15 2:19 PM, Prathyusha Kanala wrote:
> My web application was initially running on tomcat 7.0.53 and I use
> org.apache.commons.codec.binary.Base64 for encryption and
> decryption.

Just so you're clear, base64 is an encoding and not an encryption.
It's only good for taking binary data and fitting it into a 7-bit
ASCII character space.

It does not offer any protection whatsoever.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVIvnDAAoJEBzwKT+lPKRYNAAP/iyNCo3folqAH9mndJwas9nH
sSK0X8lqAPOdZBKMqtPCw+MzOWZxHfabPihuvXjoY+hW0JnSMvHVbZV834slh8ox
G8JV7+On4/3hC/iV9CwjsX/4C2yYb8XNcFbp41vTE8D1yrfEqfXBO5C2yPdOw95T
v1/Fso307RZhB9s0FjopgIbvV6J9QTyOZzUOF/CJkFCYMDxbgFuLTO7q29tkzn0w
ywPKcd4e/raW6lmV5uT85prjrojZRwBapfNNUeUb3Y1vgx1SQvvhalWFl7syd3Di
hUvHtGa6/0mrei5IMH9N1vKMNSv9eUrWQXBOp8xPp8YhH2wA1tZyl2PKIbtTdmNb
NKLe3CZlQkjq1H3wNTNT+JNeageomNunVgWDygemfiylRLxpBMCTxDHiuZAnVs6q
GLQ71E0aygpPaHRKmDbwnfcQlKoVqhN29P8PEvb8OsEUhsNyEl15XJvBb4oPPjzW
lx8AGVZaeRyLA4NJfS7yVWBgNwqJGe7J5D9gD2Wjm3TQgzPeEgYJTkBpJUFJvuV/
aY6Z90FcGBctdrs/vGHp6C41Vm/q78xTkO5x9yilUuSKILzzZeGv/IYsBf16R8sM
2WNwyaOy6xMiq+U8xSDE2HVO6Et8AVh14h0WuvImZC4D1tsAN5LTP6Mf+DUyRCrH
OPsm18vuZYVqRyK9T6/7
=XWe9
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: org.apache.commons.codec.binary.Base64 question

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-04-06 21:19 GMT+03:00 Prathyusha Kanala <kn...@gmail.com>:
> Hi,
>
> My web application was initially running on tomcat 7.0.53 and I
> use org.apache.commons.codec.binary.Base64 for encryption and decryption.
>
> Now the server has been updated to tomcat 7.0.57 and I get a java
> Nullpointer error at c.doFinal line:
>
>     public static String make(String Data) throws Exception {
>     byte[] encodedCommons;
>         Key key = generateMakeKey();
>         Cipher c = Cipher.getInstance(ALGO);
>         c.init(Cipher.ENCRYPT_MODE, key);
>        * byte[] encVal = c.doFinal(Data.getBytes());*
>         encodedCommons = Base64.encodeBase64(encVal);
>         String encryptedValue = new String(encodedCommons);
>         //BASE64Encoder benc = new BASE64Encoder();
>         //String encryptedValue = benc.encode(encVal);
>         return encryptedValue;
>     }
>
> Is the problem because I need to be using something other than the
> org.apache.commons.codec.binary.Base64?


Unlikely.

Run it with a debugger.  (Debugging Tomcat is described in Wiki / FAQ).

It is likely that your "Data" parameter has null value.

What is the reason for that null value cannot be said with that little
information that you provided. You have to figure that out by
yourself.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org