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

Posted on 2006-04-27
Last Modified: 2008-03-06
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??
Question by:hralloy
    1 Comment
    LVL 11

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Now-a-days, indirectly, postal services have been replaced by email services. Yes, whenever we hear the word "email" a lot of people only think of gmail. Some people still think that email and gmail are one and the same thing :-). Let's see some …
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
    This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now