jsr223 md5

import java.security.MessageDigest;

String content = "xxx";


MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(content.getBytes());
byte[] messageDigest = digest.digest();
vars.put("RESULT",toHexString(messageDigest));

        
 public String toHexString(byte[] b) {
    char[] HEX_DIGITS = ['0', '1', '2', '3', '4', '5','6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
    StringBuilder sb = new StringBuilder(b.length * 2);
    for (int i = 0; i < b.length; i++) {
        sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]);
        sb.append(HEX_DIGITS[b[i] & 0x0f]);
    }
    return sb.toString();
}

 

posted @ 2018-10-17 11:09  xiaodebing  阅读(188)  评论(0编辑  收藏  举报