Java MD5 Byte Array md5(byte[] bytes)

Here you can find the source of md5(byte[] bytes)

Description

md

License

Open Source License

Declaration

private static String md5(byte[] bytes) throws NoSuchAlgorithmException 

Method Source Code

//package com.java2s;

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

public class Main {
    private static String md5(byte[] bytes) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(bytes);/*from  ww  w .  j  av a  2s.  co  m*/
        byte[] bs = md.digest();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < bs.length; i++) {
            int v = bs[i] & 0xff;
            if (v < 16) {
                sb.append(0);
            }
            sb.append(Integer.toHexString(v));
        }
        return sb.toString();
    }
}

Related

  1. md5(byte[] buf)
  2. md5(byte[] buffer, int length)
  3. md5(byte[] bytes)
  4. md5(byte[] bytes)
  5. MD5(byte[] bytes)
  6. md5(byte[] bytes)
  7. md5(byte[] bytes)
  8. md5(byte[] data)
  9. md5(byte[] data)