Over a million developers have joined DZone.

Get MD5 Hash In A Few Lines Of Java

· Java Zone

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.

    1 import java.security.*;
    2 import java.math.*;
    4 public class MD5 {
    5    public static void main(String args[]) throws Exception{
    6       String s="This is a test";
    7       MessageDigest m=MessageDigest.getInstance("MD5");
    8       m.update(s.getBytes(),0,s.length());
    9       System.out.println("MD5: "+new BigInteger(1,m.digest()).toString(16));
   10    }
   11 }

The Java Zone is brought to you in partnership with JetBrains.  Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}