Java Hash Calculate getHash(String password, byte[] salt)

Here you can find the source of getHash(String password, byte[] salt)

Description

get Hash

License

Apache License

Declaration

public static byte[] getHash(String password, byte[] salt)
            throws NoSuchAlgorithmException, UnsupportedEncodingException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static byte[] getHash(String password, byte[] salt)
            throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        digest.reset();/* w w  w.  ja va 2  s . c  om*/
        digest.update(salt);
        byte[] input = digest.digest(password.getBytes("UTF-8"));

        for (int i = 0; i < 13; i++) {
            digest.reset();
            input = digest.digest(input);
        }
        return input;
    }
}

Related

  1. getHash(String input)
  2. getHash(String key)
  3. getHash(String message)
  4. getHash(String pass, String algorithm)
  5. getHash(String password, byte[] salt)
  6. getHash(String password, String bsalt)
  7. getHash(String password, String salt)
  8. getHash(String password, String salt)
  9. getHash(String phrase, String algorithm)