Here you can find the source of md5Hash(String input)
public static String md5Hash(String input)
//package com.java2s; /*//w ww. jav a 2 s . c om * Copyright (c) 2016. Sten Martinez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static MessageDigest _md5Digest = null; public static String md5Hash(String input) { if (_md5Digest == null) { try { _md5Digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { // this will not fail. e.printStackTrace(); return null; } } byte[] digest = _md5Digest.digest(input.getBytes()); StringBuilder sb = new StringBuilder(); for (byte b : digest) { sb.append(String.format("%02x", b)); } return sb.toString(); } }