Problem initializing javax.crypto.Cipher class in PHP...

The following Java class method runs fine in the JDK environment, however when calling the same class using a PHP script in ie, it returns the error "Warning: java.lang.ExceptionInInitializerError in c:\inetpub\wwwroot\test2.php on line 3".

This works fine in the JDK environment...

private String decrypt(String pData, pKey)
           javax.crypto.Cipher cipher;
            byte[] rawBytes;
            byte[] decrypted;

            rawBytes = Base64.decode(pData);
            cipher = javax.crypto.Cipher.getInstance("DES");
            cipher.init(javax.crypto.Cipher.DECRYPT_MODE, pKey);
            decrypted = cipher.doFinal(rawBytes);
            return new String(decrypted, "ASCII");

This returns the above mentioned error...

           $theClass = new Java("javax.crypto.Cipher");
           echo $theClass->getInstance("DES");

Calling the class method returns the same error (it bombs out at the getInstance call)...

      $theClass = new Java("decryptXML");
      echo $theClass->decodeXML("");

Everything is being run on the localhost in XP using iis 5.1.
I'm thinking it might be something to do with the 'DES' algorithm thats somehow not being seen by php??
Who is Participating?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.