Solved

Message Digest of char array

Posted on 2007-03-30
6
330 Views
Last Modified: 2013-12-29
I'm trying to create a message digest for a password, which is stored as a char array.

Currently, I'm doing something like this:

char [] password ;
...
MessageDigest md5=MessageDigest.getInstance("MD5");
md5.update(new String(password).getBytes("UTF8"));
byte [] md = md5.digest();

Which works. However, converting it to a string [in order to get a byte array for it] defeats the entire point of storing the password as a char array in the first place..

So is there a direct way of achieving this, without incorporating java.lang.String?


Thanks
0
Comment
Question by:InteractiveMind
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 168 total points
ID: 18822681
The password shouldn't be stored anywhere client-side, in whatever form
0
 
LVL 10

Assisted Solution

by:ADSLMark
ADSLMark earned 166 total points
ID: 18822729
A character is 2 bytes long and a byte is 1 byte long.. so if you want to convert a char[] to a byte[], then your solution seems best.
The message digest works on bytes only anyway..

Mark
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18822739
If you plump for low security and store it client-side, then of course you could store it as UTF byte[]
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 166 total points
ID: 18825626
>> byte [] md = md5.digest();

You're storing it as a byte[] so it looks fine to me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 46
why cannot we forward request once the response is committed 2 33
egit plugin on eclipse 8 40
difference of if loops 23 43
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now