Thanks Noel for the code.

Is there anything similar in JavaScript because I don't have experience
on BeanShell? 
I installed BeanShell jar file, I copied this code to tried BeanShell
Preprocessor script and provided the script file File Name (md5.bsh) and
parameter (strList) as argument but couldn't comprehend how I can call
this script by sending a string variable as parameter in my SOAP request
data. I also ran few __BeanShell functions successfully in my SOAP
request data just to make sure BeanShell in installed properly.

I would highly oblige if you could spoon feed this time in showing how
to call that code to have MD5 conversion.

Thanks, 
Zakir Sayed


-----Original Message-----
From: Noel O'Brien [mailto:[email protected]] 
Sent: Wednesday, April 08, 2009 8:59 AM
To: [email protected]
Cc: Zakir Sayed; Ronan Klyne
Subject: Re: MD5 conversion of a string.

Here's some code I use in a Beanshell PreProcessor to do MD5 encryption:

import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.TreeMap;
import java.net.URLEncoder;

.....
...
...

authSigString = strList.toString();

        // Log the auth signature string
        log.debug("authSigString: " + authSigString);
        
        digest = MessageDigest.getInstance("MD5");
        bytes = authSigString.getBytes();
        digest.reset(); 
        theHash = new StringBuilder(new BigInteger(1, 
digest.digest(bytes)).toString(16));
        // Pad to correct length
        while (theHash.length() < 32)
                theHash.insert(0, "0");

        log.debug("authSigHash: " + theHash.toString());
        return theHash.toString();

Regards,
Noel

On Wednesday 08 April 2009 16:49:16 Zakir Sayed wrote:
> Hello everybody,
>
> I need to get MD5 format of a concatenated string, which is then
> converted to Hex format. For MD5 conversion, I downloaded the js
script
> file from http://pajhome.org.uk/crypt/md5/ (also attached <<md5.js>>
).
> Also that same script file (md5.js) has 'binl2hex(binarray)' function
> which convert to hex value.. My real problem is (perhaps simple!) that
I
> don't know the way to access those functions inside that script in my
> SOAP XML/RPC data request. I mean, I don't how to call that js file in
> my SOAP request to process some variable value to get MD5 hash of it.
> Ideally I would like to add or call that hex_md5 function from
"Function
> Helper dialog" but any other possible solution would also do. So in
> brief, I need to have convert a string to MD5 through JavaScript or
> BeanShell or any other way possible.
>
> I really need that to complete my project and it's not possible to
work
> around with them, so any kind of even suggestion is highly
appreciated.
>
> --------------------
> Thanks,
> Zack Sayed.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to