Here you can find the source of md5(final String... tokens)
public static String md5(final String... tokens) throws NoSuchAlgorithmException
//package com.java2s; /*/* w w w. j a v a 2s. com*/ * Copyright (C) 2015 - 2016 Emmanuel Tourdot * * See the NOTICE file distributed with this work for additional information regarding copyright ownership. * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser * General Public License as published by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This software 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this software. * If not, see <http://www.gnu.org/licenses/>. * */ import javax.xml.bind.DatatypeConverter; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { public static final Charset CHARACTER_SET = Charset.forName("iso-8859-1"); public static String md5(final String... tokens) throws NoSuchAlgorithmException { String joinTokens = Stream.of(tokens).collect(Collectors.joining(":")); final MessageDigest md = MessageDigest.getInstance("MD5"); md.reset(); return DatatypeConverter.printHexBinary(md.digest(joinTokens.getBytes(CHARACTER_SET))).toLowerCase(); } }