Here you can find the source of md5Hex(String message)
Parameter | Description |
---|---|
message | a parameter |
public static String md5Hex(String message)
//package com.java2s; /*//from w w w.j a v a 2 s . c om * Wegas * http://wegas.albasim.ch * * Copyright (c) 2013, 2014, 2015 School of Business and Engineering Vaud, Comem * Licensed under the MIT License */ import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** * MD5 digest * * @param message * @return the MD5 digest or null if the system does not support MD5 digest */ public static String md5Hex(String message) { try { MessageDigest md = MessageDigest.getInstance("MD5"); return hex(md.digest(message.getBytes("CP1252"))); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { } return null; } /** * Given a byte array, return its hexadecimal string representation * * @param array * @return hexadecimal string representation of byte array */ public static String hex(byte[] array) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100) .substring(1, 3)); } return sb.toString(); } }