IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Encrypting a string

    Posted Thu January 30, 2003 02:47 PM

    Hi,
    I am trying to encrypt a string before writing it to the database and then trying to decrypt it while fetching from the database.
    I have a java program using Cipher class to
    Cipher pbeCipher = Cipher.getInstance(“PBEWithMD5AndDES”);

    This statement works when I try it from a Java Program. But when I create this as a webMethods Java service, I am getting an exception “exceptionjava.security.NoSuchAlgorithmException: Algorithm PBEWithMD5AndDES not implemented.”

    Any ideas?
    Thanks


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: Encrypting a string

    Posted Thu January 30, 2003 05:04 PM

    I think Cipher is not a standard java package. (javax.crypto) You need to included the corresponding jar in the classpath, and that should work.

    Quite unrelated, but the following works on my IS without any changes in classpath.

    MessageDigest messagedigest = MessageDigest.getInstance(“MD5”);


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 3.  RE: Encrypting a string

    Posted Fri January 31, 2003 05:06 PM

    Yes, Cipher is part of the JCE spec which is an optional extension for pre 1.4 JDKs.

    Are you using the same VM when running the standalone program versus the Integration Server?

    The Integration Server includes a JCE provider that has PBE, but the name has different capitialization. Can you try the following instead? PbeWithMD5AndDES_CBC

    I know…it really sucks that there aren’t standard names for specifying common cipher capabilities.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 4.  RE: Encrypting a string

    Posted Fri January 31, 2003 05:16 PM

    MessageDigest works as a one way hashing. But with Cipher I can just encrypt the string and send it and decrypt in the backend back to the actual string.
    Thats why I decided to use Cipher class.
    And I am using the same VM when I try to run the service from my local machine. The last time I heard from wm support was about the classpath for my developer being the same as the command prompt from where I am running this program. Those are the same too.

    Here is the error that I am getting.
    PBEKeySpecNoSuchAlgorithmExceptionjava.security.NoSuchAlgorithmException: Algorithm PbeWithMD5AndDES_CBC not implemented.

    Has anyone implemented the encrypting a string thing?
    Thanks


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 5.  RE: Encrypting a string

    Posted Fri January 31, 2003 06:28 PM

    Are you getting this error when running your standalone program or within the Integration Server?

    Consult your JDK documentation for the available PBE cipher names if you’re running in a standalone program (sounds like PBEWithMD5AndDES works for you).

    If you’re running a Java service within the context of the Integration Server, you need to use the one I suggested. Here’s a snippet of Java source that doesn’t throw an exception:

    try {
    Cipher cipher = Cipher.getInstance(“PbeWithMD5AndDES_CBC”);
    cipher.getIV();

    } catch (Throwable t)
    {
    t.printStackTrace();
    }


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 6.  RE: Encrypting a string

    Posted Fri January 31, 2003 06:46 PM

    Thanks a lot Ed. That worked. Now another error.
    InvalidKeyException - java.security.InvalidKeyException: Must be a PBEKey in RAW format.

    This is what I get now.
    Another question. If I get a string encrypted using this format, How do I input it into another service to get it encrypted?

    Thanks in advance!


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services