Java MD5 Sum md5Sum(byte[] data)

Here you can find the source of md5Sum(byte[] data)

Description

md Sum

License

Open Source License

Declaration

public static String md5Sum(byte[] data) 

Method Source Code

//package com.java2s;
/*   Copyright 2013 D?nes Derh?n
*
*   This file is part of BlockPhysics.// w  w  w.j  ava  2 s .  c  o  m
*
*   BlockPhysics is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*
*   BlockPhysics 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 General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with BlockPhysics.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.math.BigInteger;

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

public class Main {
    public static String md5Sum(byte[] data) {
        if (data == null)
            return "null";
        try {
            MessageDigest var3 = MessageDigest.getInstance("MD5");
            var3.update(data);
            String s = (new BigInteger(1, var3.digest())).toString(16);
            while (s.length() < 32) {
                s = "0" + s;
            }
            return s;
        } catch (NoSuchAlgorithmException var4) {
            throw new RuntimeException(var4);
        }
    }
}

Related

  1. md5sum(byte[] b)
  2. md5sum(byte[] content)
  3. md5sum(byte[] input, int length)
  4. MD5Sum(byte[] par1Data)
  5. md5sum(File f)
  6. md5sum(File f, char[] cbuf, MessageDigest digest, byte[] bbuf)