欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java md5,md5,//md5 pub

来源: javaer 分享于  点击 27962 次 点评:268

java md5,md5,//md5 pub


//md5    public static String md5(String string)     {        char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',        'e', 'f' };        try {            byte[] bytes = string.getBytes();            MessageDigest messageDigest = MessageDigest.getInstance("MD5");            messageDigest.update(bytes);            byte[] updateBytes = messageDigest.digest();            int len = updateBytes.length;            char myChar[] = new char[len * 2];            int k = 0;            for (int i = 0; i < len; i++) {                byte byte0 = updateBytes[i];                myChar[k++] = hexDigits[byte0 >>> 4 & 0x0f];                myChar[k++] = hexDigits[byte0 & 0x0f];            }        return new String(myChar);        } catch (Exception e) {        return null;        }    }//该片段来自于http://byrx.net
相关栏目:

用户点评