cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorg Heymans ...@domek.be>
Subject Re: md5 in XSP
Date Wed, 14 Apr 2004 11:48:32 GMT
I knew i came across something similar before, remember it now :)

A while ago, I implemented the md5response assertion for the jmeter 
project. Upon committing , one of their developers swapped out my usage 
of commons-codec with some JDK only code which does IIRC what you want.

//ba is your bytearray
MessageDigest md;
md = MessageDigest.getInstance("MD5");
md5Result = md.digest(ba);
StringBuffer sb = new StringBuffer(32);
for (int i = 0; i<ba.length; i++ )
	{
	int j = ba[i]&0xff;
	if (j < 16) sb.append("0");
	sb.append(Integer.toHexString(j));
	}
}

//sb contains now your md5hex string


Regards
Jorg

Joose Vettenranta wrote:

> Hi,
> 
> I'm trying to create md5-chechsum in XSP.
> 
> I already have like this:
> 
>     java.security.MessageDigest md = 
> java.security.MessageDigest.getInstance("MD5");
>     byte[] array = md.digest(password.getBytes());
> 
> And it seems to work OK. But problem is, howto get that byte-array to 
> hex-string?
> 
> I found that in catalina there is org.apache.catalina.util.MD5Encoder 
> which seems to do what I want, but I can't use that in XSP.
> 
> I've tried
> <xsp:structure>
>  <xsp:include>org.apache.catalina.util.MD5Encoder</xsp:include>
> </xsp:structure>
> 
> but it won't even compile.
> 
> So, how to get that working?
> 
> - Joose
> 
> -- 
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message