Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is jBCrypt 0.3 threadsafe?

Question says it all really. Code can be found at the following link -> http://www.mindrot.org/projects/jBCrypt/

like image 416
McGin Avatar asked Dec 02 '25 08:12

McGin


1 Answers

I strongly disagree with the existing answers, and the currently-accepted answer.

After a brief review of the source code for jBcrypt, I'm satisfied that it is thread-safe. The only instance created does not escape the scope of the key hashpw static method, and its fields are not shared with any other instances through any mechanism that I can see.

Further, I'm really confused by the complaints about the API consisting of static methods. Hashing functions are pure, and so there is no reason to not provide them via static methods. I'm actually quite glad that there is no usable userland access to instance methods, lest some fool try to do something clever (like using one instance over and over, "resetting" it to minimize allocation/GC or some such silliness).

like image 147
cemerick Avatar answered Dec 03 '25 23:12

cemerick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!