jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: Need helping creating a md5 hash
Date Sat, 20 Nov 2010 19:17:03 GMT
>vars.put("stimehash",md5hash);
vars.put expects a string as the value , not a byte[] . You have to use
vars.putObject("stimehash",md5hash);

However if you intend using this in any following HTTPSampler then you need
to figure out what the String representation is (some people convert the
byte[] array into a hex string , some convert into a BigInteger or something
like that

regards
deepak

On Sat, Nov 20, 2010 at 6:48 AM, 5942marine <jlukensow@gmail.com> wrote:

>
> Thanks Deepak for the quick reply.
>
> This is what I put into my Beanshell Pre- Processor
>
> import java.security.MessageDigest;
> String text = vars.get("time")
> MessageDigest md = MessageDigest.getInstance("MD5");
> byte[] md5hash = new byte[32];
> md.update(text.getBytes("utf-8"), 0, text.length());
> md5hash = md.digest();
> vars.put("stimehash",md5hash);
>
> Now, I have just a few questions. The paramater time is what I'm trying to
> hash. I believe I have the correct. But in the beanshell on the top, theirs
> a field:
>
> Parameters to be passed to beanshell...
>
> I assume I need to put in the parameter from my previous regex correct,
> which is "time"
>
> Secondly, after running, I got the followin in my jmeter.log
>
> 2010/11/20 07:38:25 ERROR - jmeter.util.BeanShellInterpreter: Error
> invoking
> bsh method: eval        In file: inline evaluation of: ``import
> java.security.MessageDigest; String text = vars.get("time") MessageDiges .
> .
> . '' Encountered "MessageDigest" at line 3, column 1.
>
> And lastly, the last line of the beanshell, I have the vars.put..., Which I
> assume is the correct way to create a new paramater that I can reference,
> since I need to keep the original value of the paramater time.
>
> Again, thanks for all your help!
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Need-helping-creating-a-md5-hash-tp3273251p3273660.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message