/** * Creates a new encoder. * <p> * This constructor will create a new {@code SecureRandom} * as follows: * <ol> * <li>try to create a SecureRandom using algorithm <em>NativePRNGNonBlocking</em></li> * <li>if that fails, create a default SecureRandom, i.e. without specifying an * algorithm</li> * </ol> * and then invoke {@link #SpringBasedHonoPasswordEncoder(SecureRandom, int)}. * * @see "https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/" * @see "https://hackernoon.com/hack-how-to-use-securerandom-with-kubernetes-and-docker-a375945a7b21" */ public SpringBasedHonoPasswordEncoder() { this(newSecureRandom(), DEFAULT_BCRYPT_STRENGTH); }
/** * Creates a new encoder. * <p> * This constructor will create a new {@code SecureRandom} * as follows: * <ol> * <li>try to create a SecureRandom using algorithm <em>NativePRNGNonBlocking</em></li> * <li>if that fails, create a default SecureRandom, i.e. without specifying an * algorithm</li> * </ol> * and then invoke {@link #SpringBasedHonoPasswordEncoder(SecureRandom, int)}. * * @param bcryptStrength The strength to use for creating BCrypt hashes. Value must be * >= 4 and <= 31. Note that a higher value will increase the time * it takes to compute a hash. A value around 10 is considered a good compromise * between security and computation time. * @see "https://tersesystems.com/blog/2015/12/17/the-right-way-to-use-securerandom/" * @see "https://hackernoon.com/hack-how-to-use-securerandom-with-kubernetes-and-docker-a375945a7b21" */ public SpringBasedHonoPasswordEncoder(final int bcryptStrength) { this(newSecureRandom(), bcryptStrength); }