盐值加密
1.使用long包下的UUID获取盐值
1对密码进行加密
String source=entity.getPassword();//获取原密码
String salt=UUID.randomUUID().toString();//盐值获取
SimpleHash sh=new SimpleHash(//Shiro框架
"MD5",//algorithmName 算法
source,//原密码
salt, //盐值
1);//hashIterations表示加密次数
entity.setSalt(salt);//更改盐值
entity.setPassword(sh.toHex());//更改
sh.toHex()//更改为16进制
说明:使用SimpleHash时,要添加一个shiro框架依赖
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.4.1</version>
</dependency>