Latest news:
Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now https://play.google.com/store/apps/details?id=com.akramhossin.bukharisharif
In this tutorial we will learn how to create md5 hash in java. To create md5 hash in java we need follow below steps.
Below is the example class for java to generate md5 hash
package yourpackage;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
*
*
*/
public class Encrypt {
public static String md5(String input) {
String md5 = null;
if (null == input) {
return null;
}
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes(), 0, input.length());
md5 = new BigInteger(1, digest.digest()).toString(16);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return md5;
}
}
Views : 1031