Java MD5 md5Hex(final String text)

Here you can find the source of md5Hex(final String text)

Description

md Hex

License

Apache License

Declaration

public static String md5Hex(final String text) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;

public class Main {
    public static String md5Hex(final String text) {

        try {/*from  www .j a  v a2 s  .  c o  m*/
            final byte[] bytesOfMessage = text.getBytes("UTF-8");
            final MessageDigest md = MessageDigest.getInstance("MD5");
            final byte[] digest = md.digest(bytesOfMessage);

            return DatatypeConverter.printHexBinary(digest).toLowerCase();
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }
}

Related

  1. md5bytesToHex(byte[] md5)
  2. md5Encode(byte[] content)
  3. md5Encode(String strIn)
  4. md5HashByteToString(byte[] bytes)
  5. md5HashStringToByte(String hash)
  6. md5Init()
  7. md5Memcpy(byte[] output, byte[] input, int outpos, int inpos, int len)
  8. md5ToHex(byte[] hash)
  9. md5ToString(byte[] md5sum)