Here's my problem...
I am running an imap server (cyrus) that authenticates to mysql using md5 encrypted
passwords. The md5 encryption built into the check password module for the imap
server uses the encryption method I showed you. The encryption method Turbine uses
doesn't match. Therefore authenticating to the same database doesn't work.
I could change the check password module...but this may be more difficult than
modifying the Turbine encryption method (BaseSecurityService.encryptPassword(...).
My quick fix is adding this method and calling it from the mentioned method:
public String md5Encrypt(String toEncrypt) {
StringBuffer hexString = new StringBuffer("");
MessageDigest currentAlgorithm = null;
try {
currentAlgorithm = MessageDigest.getInstance("MD5");
}
catch(Exception e) {
return "failed";
}
currentAlgorithm.reset();
currentAlgorithm.update(toEncrypt.getBytes());
byte hash[] = currentAlgorithm.digest();
for (int i = 0; i < hash.length; i++) {
if((0xFF & hash[i]) < 0x10) {
hexString.append("0" + Integer.toHexString(0xFF & hash[i]));
}
else {
hexString.append(Integer.toHexString(0xFF & hash[i]));
}
}
return hexString.toString();
}
This may not be the right way to do it (but it works for now), so if anyone has a
better solution...Please provide.
>>> Sean Legassick <[EMAIL PROTECTED]> 02/12/01 10:09 PM >>>
On Mon, Feb 12, 2001 at 09:58:49PM -0500, Ethan Adams wrote:
> I think I know the problem. Looks like your doing some additional encoded above and
>beyond md5. Ex.
Mmm, yep - the digest gets base64 encoded - whereas your "straight" MD5 is
hex encoded. (You're doing encoding "above and beyond md5" as well -
digest results are natively binary).
Check the code in BaseSecurityService.encryptPassword...
Sean
>
> When I encrypt my password using straight MD5 I get: b414965511c3fe6cd6e2adbcf0a282a3
>
> When I encrypt it using TurbineSecurity.encryptPassword I get:
>tBSWVRHD/mzW4q288KKCorg.
--
Sean Legassick
[EMAIL PROTECTED]
Ek is 'n man: niks menslik is vreemd vir my nie
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]