下面小编就为大家带来一篇java,android,MD5加密算法的实现代码(16位,32位)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
如下所示:
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Md5 { public static String getMD5(String val) throws NoSuchAlgorithmException{ MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(val.getBytes()); byte[] m = md5.digest();//加密 return getString(m); } private static String getString(byte[] b){ StringBuffer buf = new StringBuffer(); for(int i = 0; i