Java Digest digest(String message, byte[] salt)

Here you can find the source of digest(String message, byte[] salt)

Description

Create a digest from salt and a message.

License

Open Source License

Parameter

Parameter Description
message the message to calculate a digest for
salt the salt to use.

Return

the resulting digest, will be 20 bytes long.

Declaration

public static synchronized byte[] digest(String message, byte[] salt) 

Method Source Code


//package com.java2s;
import java.security.MessageDigest;

public class Main {
    private static MessageDigest md;

    /**//from  w  w w  . j  ava 2s  . c  o  m
     * Create a digest from salt and a message.
     * 
     * @param message
     *            the message to calculate a digest for
     * @param salt
     *            the salt to use.
     * @return the resulting digest, will be 20 bytes long.
     */
    public static synchronized byte[] digest(String message, byte[] salt) {
        try {
            byte[] msg = message.getBytes("UTF-8");
            md.update(salt);
            md.update(msg);
        } catch (Exception ex) {
        }
        return md.digest();
    }
}

Related

  1. digest(String digest, byte[] data)
  2. digest(String ha1, String ha2, String nonce)
  3. digest(String input, Charset charset)
  4. digest(String input, String algorithm, String encoding)
  5. digest(String key)
  6. digest(String name, String source)
  7. digest(String orgin, String algorithm)
  8. digest(String password)
  9. digest(String plain, String algorithm)