Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

message digest in the form of a String?

Thread view: 
Brandon McCombs - 23 Feb 2007 03:28 GMT
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
Filip Larsen - 23 Feb 2007 09:51 GMT
> 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,
Signature

Filip Larsen.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.