MD5WLBUtil

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.security.MessageDigest;

public class MD5WLBUtil
{
    public static byte[] md54wlb(final byte[] binaryData) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        final MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(binaryData);
        final byte[] b = md.digest();
        final StringBuffer buf = new StringBuffer("");
        for (int offset = 0; offset < b.length; ++offset) {
            int i = b[offset];
            if (i < 0) {
                i += 256;
            }
            if (i < 16) {
                buf.append("0");
            }
            buf.append(Integer.toHexString(i));
        }
        return buf.toString().getBytes();
    }
}

 

posted @ 2017-06-30 09:41  tonggc1668  阅读(154)  评论(0编辑  收藏  举报