Hi,

I'm working on a JDBC Driver to synchronize all users and passwords.

The password in database must be encrypted in MD5 hash so some people
here in the forums helped me to use this ECMAscript function:


Code:
--------------------
importClass(java.security.MessageDigest);
importClass(java.math.BigInteger);

function md5pwd(password) {
var theTextToDigestAsBytes = new
java.lang.String(String(password)).getBytes("ISO-8859-1");
var md = MessageDigest.getInstance( "MD5" );
md["update(byte[])"](theTextToDigestAsBytes);
var digest = new BigInteger["(int,byte[])"](1, md.digest()).toString(16);
return (digest);
}

--------------------


This function returns me the nspmDistributionPassword encrypted in MD5
format.

The problem is the return value is an integer so, for example, in the
case that the return is 007a213497e1af633d9308fb02cdb64c, the function
only returns 7a213497e1af633d9308fb02cdb64c without first two initial
zeros.

The password field in the database is 32 chars long, so I need to
return a string, to capture the initial 00...

If you want, you can try the function with these parameters:

md5pwd("Baracoa1")

It returns 7a213497e1af633d9308fb02cdb64c but the correct MD5 crypt is
007a213497e1af633d9308fb02cdb64c.

I'm not an expert in ECMAscript, does anybody know how to solve it? I
tried to return an String but it doesn't work.

Could you help me?

Thanks in advance!

Josep M.


--
jmriera
------------------------------------------------------------------------
jmriera's Profile: http://forums.novell.com/member.php?userid=10458
View this thread: http://forums.novell.com/showthread.php?t=451441