gpt4 book ai didi

password-encryption - jBCrypt 的默认 log_rounds 是否仍然适用于 2013 年

转载 作者:行者123 更新时间:2023-12-02 22:19:42 26 4
gpt4 key购买 nike

自 2010 年推出以来,我一直在使用开箱即用的 jBCrypt 版本 0.3。我使用默认的 getsalt() 方法,它将“log_rounds”的数量设置为 10。鉴于密码的进展破解硬件和方法,这个值作为默认值是否仍然合适,或者我应该寻找一些更高的值。

来自 javadoc 的信息...

String pw_hash = BCrypt_v03.hashpw(plain_password, BCrypt_v03.gensalt());
String strong_salt = BCrypt_v03.gensalt(10)
String stronger_salt = BCrypt_v03.gensalt(12)

The amount of work increases exponentially (2**log_rounds), so each increment is twice as much work. The default log_rounds is 10, and the valid range is 4 to 31.

最佳答案

我做了一个小测试类来检查 checkPw() 在不同 salt log_rounds 下的性能。

public void testCheckPerformance() {
int MULT = 1;
for( int i = 4; i < 31; i++) {
String salt = BCrypt_v03.gensalt(i);
String hashpw = BCrypt_v03.hashpw("my pwd", salt);
long startTs = System.currentTimeMillis();
for( int mult = 0; mult < MULT; mult++) {
assertTrue(BCrypt_v03.checkpw("my pwd", hashpw));
}
long endTs = System.currentTimeMillis();
System.out.println(""+i+": " + ((endTs-startTs)/MULT));
}
}

我的电脑是 8 核 i7 2.8GHz。结果是:

log-rounds: time in millis.
4: 3
5: 3
6: 6
7: 11
8: 22
9: 46
10: 92
11: 188
12: 349
13: 780
14: 1449
15: 2785
16: 5676
17: 11247
18: 22264
19: 45170

使用默认的 log_rounds=10 意味着单个线程可以在 0.1 秒内检查一次登录。这可能会限制单个服务器每秒可以实现的登录检查次数。

所以我想问题变成了您准备为每次密码检查花费多少时间与您希望调整系统大小以应对每秒多少次密码检查。

关于password-encryption - jBCrypt 的默认 log_rounds 是否仍然适用于 2013 年,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13897169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com