Java MD5 Byte Array md5Bytes(String message)

Here you can find the source of md5Bytes(String message)

Description

Encrypt the passed String using MD5.

License

Open Source License

Parameter

Parameter Description
message the message to encrypt

Return

the MD5 hash as 16 bytes.

Declaration

public static byte[] md5Bytes(String message) 

Method Source Code


//package com.java2s;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    /**/*from  ww  w . j a v  a2 s  . c  om*/
     * Encrypt the passed String using MD5.
     * 
     * @param message the message to encrypt
     * 
     * @return the MD5 hash as 16 bytes.
     */
    public static byte[] md5Bytes(String message) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");

            return (md.digest(message.getBytes()));
        } catch (NoSuchAlgorithmException e) {
        }

        return (null);
    }
}

Related

  1. md5(final byte[] b)
  2. md5(final byte[] bytes)
  3. md5(final byte[] data)
  4. md5Byte(String encryptStr)
  5. MD5Bytes(byte[] src)
  6. md5Bytes(String s)
  7. md5Digest(byte[] bytes)
  8. md5Hex(byte data[])
  9. md5Hex(byte[] data)