message digest in the form of a String?

B

Brandon McCombs

Hello,

I'm working on a LDAP client and currently I'm adding support for binary
attributes. The userPassword attribute is really stored as an octet
string so it isn't actually binary. Some directory servers allow for
the password to be hashed for storage so I want to support that. I can
get everything working if I store the plaintext password however when I
try to run a password against some MD5 code I get a byte[] returned.
This doesn't work though when stored in the directory server.

I want to support md4, smd4, smd5, crypt, sha, and ssha. Is there any
place that I can get Java code for these algorithms where the code
returns a string instead of a byte[]? Converting the byte[] I get now
into a string doesn't work either. I have an older MD5 Crypt class I
downloaded a while back and it returns a String but that won't help for
all the algorithms I want to support.

thanks
 
F

Filip Larsen

Brandon said:
I want to support md4, smd4, smd5, crypt, sha, and ssha. Is there any
place that I can get Java code for these algorithms where the code
returns a string instead of a byte[]?

The common thing is to convert the byte array into either a string of
hexadecimal-digits (giving 2 characters for every byte in the hash) or
to base64 encode it (giving 4 characters for every 3 bytes in the hash).
You can then either string compare these "ASCII-encoded" hashes or
decode the encoded hashes back to a byte array if you somehow need those.

Everything else being equal I would go with the simplest approach, which
is to hex-encode the bytes and just compare the resulting strings.


Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,588
Members
45,099
Latest member
AmbrosePri
Top