Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Message Digest of char array

Posted on 2007-03-30
6
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 672 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 664 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 664 total points
ID: 18825626
>> byte [] md = md5.digest();

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

604 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