Well, it is a motivated question, but it does not seem to be that
problem. The column has a char length of 50 and I can generate longer
keys into the column, with my own code. 

The only place where my code and the James code differs is where it
converts the bytes to a String. My code:

String hash = (new sun.misc.BASE64Encoder()).encode(digest); 

Where James has this code:

bos = new ByteArrayOutputStream();
OutputStream encodedStream = MimeUtility.encode(bos, "base64");
encodedStream.write(digest);
return bos.toString("iso-8859-1");

But they really shouldn't differ, it just seems to be different ways to
do the base64 encoding.

Unfortunately I couldn't get the James file to run. The MimeUtility
seems to reference the com.sun.mail package, and I really thought that
package was included in J2EE 1.4, which I am running. The error below is
produced from MimeUtility.encode():

java.lang.NoClassDefFoundError: com/sun/mail/util/BASE64DecoderStream
        at DigestUtil.digestString(DigestUtil.java:190)
        at DigestUtil.main(DigestUtil.java:110)
Exception in thread "main" 

So either my code is padding the output with some sort of extra hash
values, or the James server is only storing a subset of the hash for
some reason. The problem can be solved by truncating my output but it
would be nicer to have the hashes to match. Also I  wouldn't mind using
James own hash generator if I only could get it to work. :(

Regards Erik Beijnoff

-----Ursprungligt meddelande-----
Fr�n: Brian Austin [mailto:[EMAIL PROTECTED] 
Skickat: 01 December 2003 23:17
Till: James Users List
�mne: Re: Problem with trimmed SHA stored passwords in database


I know it sounds too obvious..
database field length?

regards

b

----- Original Message -----
From: "Erik Beijnoff" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 2:39 AM
Subject: Problem with trimmed SHA stored passwords in database


> Hello. I'm using James connected to a SQL Server, storing the users in

> a table. I'm having a trimming problem with the password hash 
> generated by James. After adding a user with telnet with the password 
> "testing", the
key
> below is stored in the db:
>
> 3HJK8Y+91OWRifX+dopfgxFS
>
> However, when I generate the password directly from code, I get a 
> slightly longer hash:
>
> 3HJK8Y+91OWRifX+dopfgxFScFA=
>
> As you can see, the last few characters generated from my own code is 
> cropped in the password generated by James. This means that I'm having

> a
bit
> of a problem adding users with anything else then James and telnet. 
> Any
idea
> why this occurrs and how to solve it?
>
> Regards Erik Beijnoff
>
> Password generating code below:
>
> ----------------------------------------------------------------------
> -
>
> String hashThis= "testing";
>
> try {
>
> byte[] bytes= hashThis.getBytes("UTF-8");
>
> java.security.MessageDigest messageDigest= 
> java.security.MessageDigest.getInstance("SHA");
>
> messageDigest.update(bytes);
>
>
> byte[] raw= messageDigest.digest();
>
>
> String hash = (new sun.misc.BASE64Encoder()).encode(raw);
>
>
> System.out.println("Result:" + hash);
>
> } catch (java.security.NoSuchAlgorithmException ne) {
>
> //
>
> } catch (java.io.UnsupportedEncodingException ue) {
>
> //
>
> }
>
> ----------------------------------------------------------------------
> -
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>




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





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

Reply via email to