Java MD5 md5(String toDigest)

Here you can find the source of md5(String toDigest)

Description

md

License

Creative Commons License

Declaration

public static String md5(String toDigest) 

Method Source Code

//package com.java2s;
/**/*from  w  ww .  jav  a2  s .c o  m*/
 * The New Economy Minecraft Server Plugin
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
 * Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
 * Created by creatorfromhell on 06/30/2017.
 */

import javax.xml.bind.DatatypeConverter;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String md5(String toDigest) {
        String toReturn = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(toDigest.getBytes());
            byte[] digest = md.digest();
            toReturn = DatatypeConverter.printHexBinary(digest).toUpperCase();
            md = null;
            digest = null;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return toReturn;
    }
}

Related

  1. looksLikeValidMd5(String possibleMd5)
  2. md5(File f)
  3. md5(final String text)
  4. md5(final String... tokens)
  5. md5(String source)
  6. md5_hh(int C, int B, int G, int F, int A, int E, int D)
  7. md5_id(byte[] md5digest)
  8. md5bytesToHex(byte[] md5)
  9. md5Encode(byte[] content)