spring boot - BCryptPasswordEncoder affects startup time of server -
why strength of bcryptpasswordencoder affect startup time of server? there no hashes generated @ startup, i'm wondering why have effect on startup.
of course, understand checking whether password matches takes time, @ start strange.
code looks this:
@bean public bcryptpasswordencoder passwordencoder() { return new bcryptpasswordencoder(17); // affects startup time tremendously } @autowired bcryptpasswordencoder bcryptencoder; @autowired customuserdetailsservice userdetailsservice; @override protected void configure(authenticationmanagerbuilder auth) throws exception { auth.userdetailsservice(userdetailsservice) .passwordencoder(bcryptencoder); }
the constructor of bcryptpasswordencoder not doing on startup depending on password strength :
public bcryptpasswordencoder(int strength) { this(strength, null); } public bcryptpasswordencoder(int strength, securerandom random) { if (strength != -1 && (strength < bcrypt.min_log_rounds || strength > bcrypt.max_log_rounds)) { throw new illegalargumentexception("bad strength"); } this.strength = strength; this.random = random; } having seen this, dont think changing strength parameter can increase startup time described.
but when use encrypter, 'strength' sure impact performance. may encrypting many passwords somewhere @ startup ?
Comments
Post a Comment