Hi,

while integrating the crypto service with security service in Fulcrum,
I noticed the following thing:

In Turbine 2 (and in all Code that I've seen and in the Crypto
Service), this is used to do Message Digest encryption:

--- cut ---
MessageDigest md = MessageDigest.getInstance(<encoding algorithm name>);
byte[] digest = md.digest(password.getBytes("UTF-8"));
ByteArrayOutputStream bas = new ByteArrayOutputStream(digest.length + digest.length / 
3 + 1);
OutputStream encodedStream = MimeUtility.encode(bas, "base64");
encodedStream.write(digest);
return bas.toString();
--- cut ---

In Fulcrum this code is changed to:

--- cut ---
MessageDigest md = MessageDigest.getInstance(<encoding algorithm name>);
byte[] digest = md.digest(password.getBytes("UTF-8"));

byte[] encodedDigest = Base64.encode(digest);
return (encodedDigest == null ? null : new String(encodedDigest));
--- cut ---

Which is cool because it uses Commons but unfortunately delivers
different results! There is no information in CVS where this code
change comes from. :-(

In my test case, the first algorithm gives you:

MD5(Oeltanks) = XSop0mncK19Ii2r2CUe2

the second returns:

MD5(Oeltanks) = XSop0mncK19Ii2r2CUe29w==

Note that this is the same but "9w==" is attached. The problem must be
in the base64 encoding; if it were in MD5, the sums would be totally
different; not just some digits attached.

Unfortunately it is possible that both results are wrong: using perl
gives me:

%  perl -e 'use Digest::MD5 qw(md5_base64); print md5_base64("Oeltanks");'
XSop0mncK19Ii2r2CUe29w

So I get the "9w" but not the "==". 

Any Commons hackers around? It would be great to get the same result
as in perl...

I'm now a little reluctant to change the Cryptoservice over to the
Commons algorithm though I like it more than the Stream juggling in
the old one.

        Regards
                Henning





-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     [EMAIL PROTECTED]

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   [EMAIL PROTECTED]
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to