PDA

View Full Version : authenticate password via java


pokermagic2
12-20-2008, 05:52 PM
Hello. I have a website done in java/.jsp and has a forums and user pages to check status on RMA's, rebates, etc. We are moving to vBulletin and i wanted to just have 1 user table. Once the data has been migrated to vBulletin, i still want to log in the user from a .jsp page if they are not in the Forums. I see from forum posts that the password is created using MD5 like such MD5(MD5($password) + $salt).

I tried to do the same on the java end using some quick code, but my result is not the same. Has anyone done this or can suggest anything that i can match the codes to authenticate the user?

My java code is below.

public static synchronized String encrypt(String plaintext) throws Exception
{
MessageDigest md = null;
try
{
md = MessageDigest.getInstance("MD5"); //step 2
}
catch(NoSuchAlgorithmException e)
{
throw new Exception(e.getMessage());
}


try
{
md.update(plaintext.getBytes("UTF-8")); //step 3
} catch(UnsupportedEncodingException e) {
throw new Exception(e.getMessage());
}

byte raw[] = md.digest(); //step 4
String secbyte = new String(raw);
System.out.println("secbyte is " + secbyte);
plaintext = secbyte + "24V";
System.out.println("plaintext is " + plaintext);
md.update(plaintext.getBytes("UTF-8"));
byte raws[] = md.digest();
System.out.println("raws is " + raws);


String hash = (new BASE64Encoder()).encode(raws); //step 5
return hash; //step 6
}

the password i am trying to encrypt is "test"

on the code above it comes out -> LXwYEAzMhmx4kV0JkJgNhA==

yet in the vBulletin db it's -> 1a0303cc71581a9688ba2998b118378e

my $salt is "24V"

thanks for any help.

Dismounted
12-21-2008, 02:40 AM
on the code above it comes out -> LXwYEAzMhmx4kV0JkJgNhA==
This looks like a Base 64 encoded string. :)