import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; public static void main(String[] args) { String password = "123456"; BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(6); String hashedPassword1 = passwordEncoder.encode(password); String hashedPassword2 = passwordEncoder.encode(password); String hashedPassword3 = passwordEncoder.encode(password); String hashedPassword4 = passwordEncoder.encode(password); System.out.println(hashedPassword1); System.out.println(hashedPassword2); System.out.println(hashedPassword3); System.out.println(hashedPassword4); boolean match1 = passwordEncoder.matches(password, hashedPassword1); System.out.println(match1); boolean match2 = passwordEncoder.matches(password, hashedPassword2); System.out.println(match2); boolean match3 = passwordEncoder.matches(password, hashedPassword3); System.out.println(match3); boolean match4 = passwordEncoder.matches(password, hashedPassword4); System.out.println(match4); }
$2a$06$Her60GVyob.Ndhay4KbH3OShEeuyy0SNQStZ.Pl90HWiN7UEETv0i $2a$06$Vbtkylrumz6/ozMVE4x0Xuh7yCycKrhZGYrYjY2ejF3CudNhZImjO $2a$06$S5mqTvjnsmNwEVUOY15Hs.6tuwGmgRxVdYIMPiUKwrQv3/O86akni $2a$06$k.4qWZ8KDd6K8qSbtXnjX.A9O2ZJtDYlp4ebk7awEThk5pCI3lbIS true true true true
登录注册还是用https安全。
在客户端base64或者md5什么的真心没用,我直接监听到你所谓的密文,然后用脚本发起一个http请求就可以登录上去了。
http在网络上是明文传输的,代理和网关都能够看到所有的数据,在同一局域网内也可以被嗅探到,你可以开个wireshark抓下局域网的包试试看。
我认为加密也没有提高什么攻击难度,因为攻击者就没必要去解密原始密码,能登录上去就表示目标已经实现了,所以,难度没有提高。
另外,在客户端md5后,服务端怎么把原始密码还原出来,不能数据库直接存md5吧?
所以要选择加密算法的话,还要让服务端能还原出来原始密码。
然后:
如果是简单的base64下,这种算法对安全性没什么提高呀,base64又不是加密算法,它的作用就是编码下而已,如果这个能难道黑客的话,那他可以洗洗睡了。
其他的诸如非对称加密之类的算法当然可以,但是这不是https提供的功能么?而且https提供的安全保障还可以应对其他的攻击。
http://segmentfault.com/q/1010000000926027
相关推荐
主要介绍了Spring security BCryptPasswordEncoder密码验证原理详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
SpringPasswordEncoder 一个简单的工具可以生成spring 哈希值,并且还可以验证现有哈希值。...建造$ mvn软件包用法$ java -jar target/spring-password-0.1.0.jar -e : Encode password into hash (default: false) -v ...
Bcrypt加密类相关jar包
springsecurity中使用MD5编码所需要的JAR包,包括org.springframework.security.authentication.encoding.Md5PasswordEncoder
springboot_springsecurity_jwt_demo
1234项目功能SpringMVC Spring安全冬眠玛文JSP 邮件API 文件上传文件压缩器带有文件上传功能的Ajax呼叫JSTL JSP ...BCryptPasswordEncoder 导入org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder...
SSM框架中使用spring_security实现不同用户之间的权限管理。简单的xml配置入门,连接MySQL数据库进行权限匹配管理,以及对使用spring_security自身BCryptPasswordEncoder类进行加密后的登录处理。
书店书店实习项目在这个项目中,我正在使用Java,JPA,H2和Thymeleaf开发数据库。 这是一个实践项目,我正在... BCryptPasswordEncoder用于散列,尽管当您添加新用户时,密码必须以已经散列的格式给出,即使用BCrypt计
bcrypt.net-下一个具有... HashPassword ( " my password " ); 注意:尽管此库允许您提供自己的盐,但是强烈建议您允许该库为您生成盐。 提供这些方法是为了保持兼容性,以及可能需要使用它们的更高级的跨平台要求。...
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder (); String hashedPassword = passwordEncoder . encode(u . getPassword()); u . setPassword(hashedPassword); return dao . save(u)...
登录用户角色电子邮件演示项目。 这是一个后端应用程序,使用户可以使用全名,电子邮件地址和密码进行注册,并为他们授予角色用户... 数据将存储在postgreSQL数据库中,并且密码已使用BCryptPasswordEncoder进行编码。