Java MD5 md5(final String... tokens)

Here you can find the source of md5(final String... tokens)

Description

md

License

Open Source License

Declaration

public static String md5(final String... tokens) throws NoSuchAlgorithmException 

Method Source Code


//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();
    }
}

Related

  1. inputStreamMD5(InputStream entity)
  2. isEtagAlsoAnMD5Hash(String etag)
  3. looksLikeValidMd5(String possibleMd5)
  4. md5(File f)
  5. md5(final String text)
  6. md5(String source)
  7. md5(String toDigest)
  8. md5_hh(int C, int B, int G, int F, int A, int E, int D)
  9. md5_id(byte[] md5digest)