Forum Stats

  • 3,853,777 Users
  • 2,264,267 Discussions
  • 7,905,444 Comments

Discussions

How to Use MessageDigest

843811
843811 Member Posts: 49,851 Green Ribbon
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

This discussion has been closed.