Java Salt Value Create generateSalt()

Here you can find the source of generateSalt()

Description

generate Salt

License

Open Source License

Declaration

public static byte[] generateSalt() 

Method Source Code


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

import java.security.SecureRandom;
import java.util.function.Supplier;

public class Main {
    private static final ThreadLocal<SecureRandom> SECURERANDOMS = new ThreadLocal<>();

    public static byte[] generateSalt() {
        return newByteGenerator(64).get();
    }//from  www  . ja v  a 2s  .c o m

    public static Supplier<byte[]> newByteGenerator(int size) {
        return () -> {
            byte[] iv = new byte[size];
            if (SECURERANDOMS.get() == null)
                SECURERANDOMS.set(new SecureRandom());
            SECURERANDOMS.get().nextBytes(iv);
            return iv;
        };
    }
}

Related

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