Java Utililty Methods MD5 String

List of utility methods to do MD5 String

Description

The list of methods to do MD5 String are organized into topic(s).

Method

Stringmd5(final InputStream in)
Read all of the input stream and return it's MD5 digest.
return md5(in, 1024);
Stringmd5(final String data)
Creates the MD5 hash for a given string.
final StringBuilder hash = new StringBuilder();
try {
    final MessageDigest digester = MessageDigest.getInstance("MD5");
    final byte[] hashedData = digester.digest(data.getBytes());
    for (final byte b : hashedData) {
        hash.append(String.format("%02x", b));
} catch (final NoSuchAlgorithmException e) {
...
Stringmd5(final String inData)
Create an MD5 hash from the given string.
StringBuilder hexBuilder = new StringBuilder();
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(inData.getBytes());
for (byte b : digest.digest()) {
    hexBuilder.append(Integer.toHexString(b & 0x00FF));
return hexBuilder.toString();
Stringmd5(final String input)
md
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(input.getBytes());
    byte[] output = md.digest();
    return bytesToHex(output);
} catch (Exception e) {
    e.printStackTrace();
return input;
Stringmd5(final String input)
Returns the MD5 of the given string
if (null == input) {
    return null;
try {
    final MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.update(input.getBytes(), 0, input.length());
    return new BigInteger(1, digest.digest()).toString(16);
} catch (final NoSuchAlgorithmException e) {
...
Stringmd5(final String message)
Generates de MD5 checksum for the specified message.
byte[] res;
try {
    MessageDigest instance = MessageDigest.getInstance("MD5");
    instance.reset();
    instance.update(message.getBytes());
    res = instance.digest();
} catch (NoSuchAlgorithmException ex) {
    throw new RuntimeException(ex);
...
Stringmd5(final String s)
Fast and dirty MD5 hasher.
if (s == null) {
    throw new NullPointerException();
if (s.length() == 0) {
    return "";
try {
    MessageDigest md5 = MessageDigest.getInstance("MD5");
...
Stringmd5(final String s)
md
final String MD5 = "MD5";
try {
    MessageDigest digest = java.security.MessageDigest.getInstance(MD5);
    digest.update(s.getBytes());
    byte messageDigest[] = digest.digest();
    StringBuilder hexString = new StringBuilder();
    for (byte aMessageDigest : messageDigest) {
        String h = Integer.toHexString(0xFF & aMessageDigest);
...
Stringmd5(final String str)
This function transform a string into its md5 representation.
final byte[] hash = MessageDigest.getInstance("MD5").digest(str.getBytes());
final StringBuilder res = new StringBuilder();
for (final byte element : hash) {
    final String hex = Integer.toHexString(element);
    if (hex.length() == 1)
        res.append('0').append(hex.charAt(hex.length() - 1));
    else
        res.append(hex.substring(hex.length() - 2));
...
Stringmd5(final String string)
md
try {
    final MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.update(string.getBytes());
    final byte[] bytes = digest.digest();
    final StringBuilder md5 = new StringBuilder();
    for (final byte b : bytes) {
        final String hex = Integer.toHexString(MASK & b);
        if (hex.length() == 1) {
...