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.

Reply via email to