This is one of the most useful things in android.
We can use the MD5 algorithm to create a hash of any string we want.
Here is the code for doing that.
Check the LogCat for output.

package pack.coderzheaven;

import java.math.BigInteger;
import android.os.Bundle;

public class MD5Demo extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        System.out.println("Hash Word : " + createHash("CoderzHeaven"));

    static public String createHash(String word) {
    	   String created_hash = null;
    	   try {
    	      MessageDigest md5 = MessageDigest.getInstance("MD5");
    	      BigInteger hash = new BigInteger(1, md5.digest());
    	      created_hash = hash.toString(16);
    	   } catch (NoSuchAlgorithmException e) {
    	      System.out.println("Exception : " + e.getMessage());
    	   return created_hash;

Please leave your valuable comments on this post.


Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.