0 votes
1 view
ago in Java by (1.2k points)

Is there any method to generate MD5 hash of a string in Java?

1 Answer

0 votes
ago by (6.7k points)

You can use MessageDigest class to generate an instance of MD5 hash:

 MessageDigest md = MessageDigest.getInstance("SHA-256");

 try {


     MessageDigest tc1 = md.clone();

     byte[] toChapter1Digest = tc1.digest();



 } catch (CloneNotSupportedException cnse) {

     throw new DigestException("couldn't make digest of partial content");


To know more about it click here.