之前某网站密码明文的就存了.. 很是BS, 相当的不负责啊. 码农们随便encoding一下就少了多少损失啊..
此前一直对这部分感兴趣, 一是不太懂的时候对这个感觉比较神奇. 二是有个用123456的md5值随便百度一下.... 又明文了.
之前用过spring security, 里面的 sha-256的加密算法. 里面可以传一个salt, 把用户名做过salt 还有一个salt 用的是一个加密过再base64的应用名字, 也是256字节的很长一串.
用起来就效果不错. 看着特别迷糊. 也是当时 spring security 里比较复杂的加密算法了.
今天看spring-security 3.1.RELEASE 里多了个 crypto 的 jar, 里面专门做加密的. 而且不需要且不支持salt. 看看里面的代码, 发现有如下一段
解码用的这个类 : org.springframework.security.crypto.bcrypt.BCrypt.
很是神奇啊.. 具体的算法不懂. 先发出来, 以后有时间再研究
此前一直对这部分感兴趣, 一是不太懂的时候对这个感觉比较神奇. 二是有个用123456的md5值随便百度一下.... 又明文了.
之前用过spring security, 里面的 sha-256的加密算法. 里面可以传一个salt, 把用户名做过salt 还有一个salt 用的是一个加密过再base64的应用名字, 也是256字节的很长一串.
用起来就效果不错. 看着特别迷糊. 也是当时 spring security 里比较复杂的加密算法了.
今天看spring-security 3.1.RELEASE 里多了个 crypto 的 jar, 里面专门做加密的. 而且不需要且不支持salt. 看看里面的代码, 发现有如下一段
/**
* Implementation of PasswordEncoder that uses the BCrypt strong hashing function. Clients can optionally supply a
* "strength" (a.k.a. log rounds in BCrypt) and a SecureRandom instance. The larger the strength parameter the more work
* will have to be done (exponentially) to hash the passwords. The default value is 10.
*
* @author Dave Syer
*
*/
public class BCryptPasswordEncoder implements PasswordEncoder {
解码用的这个类 : org.springframework.security.crypto.bcrypt.BCrypt.
很是神奇啊.. 具体的算法不懂. 先发出来, 以后有时间再研究