I appreciate your reply. Upon experimenting a little bit, I could run that code in BeanShell sampler. It is working great though but not exactly in my SOAP request. So I'm using UDV to pass & calculate & return the MD5 of the string through.
It was really helpful. Thanks a ton. Thanks, Zakir Sayed From: Noel O'Brien [mailto:[email protected]] Sent: Thursday, April 09, 2009 1:34 AM To: [email protected] Cc: Zakir Sayed; Ronan Klyne Subject: Re: MD5 conversion of a string. I only posted a snippet, because some of the other code has company specific details in it, but what I posted shows how to create a hash. AFAIK, you can put Java (but not javascript) code straight into a beanshell script and it will work, but I may have wrong. So if you've got any Java experience, that will help In my case, `strList` is a java StringBuffer used to build up a lot of substrings into the string I want to get the hash of (`authSigString`). Also the code I posted was part of a function, as you can see from the return statement at the end. You can run this code procedurally (without methods), you just need to build your string before the block of code I posted and then manipulate your SOAP request to include the hash. I don't have any experience with SOAP requests unfortunately Regards, Noel On Thursday 09 April 2009 00:14:29 Zakir Sayed wrote: > 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]

