Java用于BCrypt加密的实现
发布时间
阅读量:
阅读量
描述
BCrypt是一种广泛应用的加密技术,相较于MD5而言,其具备多对多的特性,在数据库中存储加密信息方面具有较高的实用性。Spring Security框架中已内置了BCrypt算法的支持,而对于一般项目而言,也可以借助第三方开发的工具类来实现相关功能,本文将简要介绍该工具类的基本使用方法。
使用
下载
=>下载该工具类
加密机制与验证分析
// Hash a password for the first time
String hashed = BCrypt.hashpw(password, BCrypt.gensalt());
// gensalt's log_rounds parameter determines the complexity
// the work factor is 2**log_rounds, and the default is 10
String hashed = BCrypt.hashpw(password, BCrypt.gensalt(12));
// Check that an unencrypted password mat
全部评论 (0)
还没有任何评论哟~
