Here you can find the source of digestMD5(String buffer, String key)
Parameter | Description |
---|---|
buffer | buffer. |
key | key is secret key (password or something else which isn't going to be passed over network). |
Parameter | Description |
---|
public static byte[] digestMD5(String buffer, String key) throws NoSuchAlgorithmException
//package com.java2s; // the terms of the GNU General Public License as published by the Free Software Foundation; import java.security.NoSuchAlgorithmException; import java.security.MessageDigest; public class Main { /**/*w w w.j a va2 s .c o m*/ * Digests the buffer with key using MD5 algorithm. * * @param buffer buffer. * @param key key is secret key (password or something else which isn't * going to be passed over network). * * @return digested buffer. * * @throws java.security.NoSuchAlgorithmException if there's no MD5 algorithm implemetation. */ public static byte[] digestMD5(String buffer, String key) throws NoSuchAlgorithmException { MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(buffer.getBytes()); return md5.digest(key.getBytes()); } }