Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Use MessageDigest

843811Jul 2 2001 — edited Aug 3 2001
Hi All

Someone please help me to use MessageDigest Class.

Actually i want to digest the password field.

import java.security.*;

public class Class1
{

public static void main(String[] args)
{
try
{
MessageDigest md5 = MessageDigest.getInstance("MD5");
String str = "password";
byte[] b = new byte[100];
byte[] b1 = null;
b=str.getBytes();

md5.update(b);
b1 = md5.digest();
System.out.println(b.toString());
}catch(NoSuchAlgorithmException nsae)
{
nsae.printStackTrace();
}
}

}

is the way, that i am using MessageDigest correct ?

Thanks
Shan

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 31 2001
Added on Jul 2 2001
1 comment
96 views