Java Salt Value Create generateSalt(int length)

Here you can find the source of generateSalt(int length)

Description

generate Salt

License

Open Source License

Declaration

public static byte[] generateSalt(int length) 

Method Source Code

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

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

public class Main {
    public static byte[] generateSalt(int length) {
        byte[] salt = new byte[length];
        SecureRandom rnd = null;/*from   w w w .  ja  v  a  2  s .  c  o m*/
        try {
            rnd = SecureRandom.getInstanceStrong();
        } catch (NoSuchAlgorithmException e) {
            rnd = new SecureRandom();
        }
        rnd.nextBytes(salt);
        return salt;
    }
}

Related

  1. generateSalt()
  2. generateSalt()
  3. generateSalt(final Integer size)
  4. generateSalt(int bits)
  5. generateSalt(int byteSize)
  6. generateSalt(int numberOfBytes)
  7. generateSalt(int numBytes)
  8. generateSaltAESPBKDF2()
  9. generateSaltedPassword(final String password, byte[] salt, int iterationsCount, String hmacName)