Java Salt Value Create generateSalt()

Here you can find the source of generateSalt()

Description

This method used to generate salt

License

Open Source License

Exception

Parameter Description
NoSuchAlgorithmException an exception

Declaration

public static byte[] generateSalt() throws NoSuchAlgorithmException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class Main {
    private static final int SALT_BYTE_SIZE = 24;

    /**/*from  w w w.  jav a  2s  .  c om*/
     * This method used to generate salt 
     * @return
     * @throws NoSuchAlgorithmException
     */
    public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = new SecureRandom();
        byte[] salt = new byte[SALT_BYTE_SIZE];
        random.nextBytes(salt);
        return salt;
    }
}

Related

  1. generateSalt()
  2. generateSalt()
  3. generateSalt()
  4. generateSalt()
  5. generateSalt()
  6. generateSalt()
  7. generateSalt()
  8. generateSalt()
  9. generateSalt(final Integer size)