安全工具/Bcrypt哈希生成器
Bcrypt哈希生成器
使用bcrypt算法哈希和验证密码
生成哈希
验证密码
Bcrypt Hash Guide
Learn about secure password hashing with bcrypt
What is Bcrypt?
Bcrypt is a password hashing function designed to be slow and computationally expensive, making it resistant to brute-force attacks. It automatically handles salting (adding random data) and allows adjustable work factors (cost rounds) to increase security over time as hardware improves.
How to Use
- Enter the password you want to hash
- Adjust the cost rounds (higher = more secure but slower)
- Click 'Generate Hash' to create the bcrypt hash
- To verify, enter both the password and hash, then click 'Verify'
Best Practices
- Use cost rounds of 10-12 for a good balance of security and performance
- Never store plain passwords - always hash them with bcrypt
- Increase cost rounds periodically as hardware becomes faster
Security Note
Bcrypt is the recommended algorithm for password hashing. Each hash includes a unique salt, so the same password will produce different hashes. The cost factor makes bcrypt resistant to GPU-based attacks, unlike SHA or MD5.
常见问题
为什么bcrypt被推荐用于密码哈希?
bcrypt有三个关键特性:1) 内置加盐防止彩虹表攻击,2) 可调节的工作因子使其可以随硬件发展而增加安全性,3) 故意设计得很慢,使暴力破解成本极高。它是经过20多年实战验证的算法。
工作因子(cost rounds)应该设多少?
工作因子每增加1,计算时间翻倍。建议值:2024年一般应用10-12,高安全需求12-14。目标是验证一次密码需要100-500毫秒。过低不安全,过高影响用户体验和服务器负载。随时间推移应逐渐增加。
相同密码为什么产生不同的bcrypt哈希?
bcrypt每次哈希时自动生成随机盐并包含在输出中。因此相同密码会产生不同的哈希值,但验证时可以正确匹配。这防止了通过比较哈希值判断密码是否相同。
bcrypt、scrypt和Argon2哪个更好?
三者都是优秀的密码哈希算法。bcrypt历史悠久、广泛支持。scrypt抵抗GPU/ASIC攻击更好。Argon2是2015年密码哈希竞赛获胜者,被认为是最先进的,但支持度不如bcrypt广泛。对于新项目推荐Argon2,现有项目用bcrypt也很好。
如何升级旧的bcrypt工作因子?
用户下次成功登录时可以升级:验证密码后用新的工作因子重新哈希并更新存储。可以在哈希值中检查现有工作因子($2a$10$...中的10就是工作因子),如果低于目标值则触发升级。