现在大多数项目中都会通过盐值给密码加密,使数据更加安全,下面就简单介绍一下Shiro自带的加密方式和一个简单的登录示例。

一、数据库中用户表的设计

1.1用户表的结构设计


项目文件目录

2、下面贴一些基本的配置文件

2.1、jdbc.properties

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://ip/instance?;useUnicode=true;characterEncoding=UTF-8;autoReconnect=true
username=root
password=123456
#定义初始连接数
initialSize=0
#定义最大连接数
maxActive=20
#定义最小空闲
minIdle=1
#定义最长等待时间
maxWait=60000
#shiro哈希迭代次数
hashIterations=2
#shiro加密算法名称
algorithmName=md5

2.2、spring-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"><context:component-scan base-package="com.icinfo.controller" use-default-filters="false"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/><context:include-filter type="annotation"expression="org.springframework.web.bind.annotation.ControllerAdvice"/></context:component-scan><!-- 引入配置文件 --><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location" value="classpath:jdbc.properties" /></bean><!-- 根据路径后缀选择不同视图 --><bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"><property name="contentNegotiationManager"><bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"><property name="mediaTypes"><map><entry key="json" value="application/json"/><entry key="xml" value="application/xml"/><entry key="html" value="text/html"/></map></property><property name="defaultContentType" value="text/html"/><!-- 忽略Accept Header--><property name="ignoreAcceptHeader" value="true"/><!-- 关闭 ?format=json的支持 --><property name="favorParameter" value="false"/><!-- 开启扩展名支持 --><property name="favorPathExtension" value="true"/></bean></property><property name="viewResolvers"><list><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="viewClass"value="org.springframework.web.servlet.view.JstlView"/><property name="contentType" value="text/html"/><property name="prefix" value="/WEB-INF/views/page/"/><property name="suffix" value=".jsp"/></bean></list></property><property name="defaultViews"><list><bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"><property name="prettyPrint" value="false"/></bean><bean class="org.springframework.web.servlet.view.xml.MappingJackson2XmlView"/></list></property></bean><mvc:default-servlet-handler/><mvc:annotation-driven/><mvc:resources mapping="/js/**" location="/WEB-INF/views/js/" cache-period="1296000"/>
</beans>

2.3、spring-mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.1.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsd"><!-- 使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入 --><context:component-scan base-package="com.icinfo"><context:exclude-filter type="annotation"expression="org.springframework.stereotype.Controller"/><context:exclude-filter type="annotation"expression="org.springframework.web.bind.annotation.ControllerAdvice"/></context:component-scan><!-- 引入配置文件 --><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location" value="classpath:jdbc.properties" /></bean><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"destroy-method="close"><property name="driverClassName" value="${driver}" /><property name="url" value="${url}" /><property name="username" value="${username}" /><property name="password" value="${password}" /><!-- 初始化连接大小 --><property name="initialSize" value="${initialSize}"></property><!-- 连接池最大数量 --><property name="maxActive" value="${maxActive}"></property><!-- 连接池最小空闲 --><property name="minIdle" value="${minIdle}"></property><!-- 获取连接最大等待时间 --><property name="maxWait" value="${maxWait}"></property></bean><!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><!-- 自动扫描mapping.xml文件 --><property name="mapperLocations" value="classpath:com/icinfo/mapper/mapping/*Mapper.xml"></property></bean><!-- DAO接口所在包名,Spring会自动查找其下的类 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.icinfo.mapper" /><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property></bean><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><import resource="classpath:spring-shiro-demo.xml"/>
</beans>

2.4、spring-shiro-demo.xml

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 配置/** = anon 是为了防止js和css的路径被拦截 --><bean id="filterChainDefinitions" class="java.lang.String"><constructor-arg><value>/index/goLogin = anon/index/login = anon/index/logout = logout/user/** = authc/index/** = authc/** = anon</value></constructor-arg></bean><bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"><property name="loginUrl" value="/index/goLogin"/><property name="successUrl" value="/admin"/><property name="unauthorizedUrl" value="/admin/error/unauthorized"/><property name="securityManager" ref="securityManager"/><property name="filterChainDefinitions" ref="filterChainDefinitions" /><property name="filters"><map><entry key="logout" value-ref="logout"></entry></map></property></bean><bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter"><property name="redirectUrl" value="/index/goLogin"/></bean><!-- 安全管理器 --><bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"><!--<property name="sessionManager" ref="defaultWebSessionManager"/>--><property name="realm" ref="securityAuthorizingRealm"/></bean><!-- 自定义的Realm --><bean id="securityAuthorizingRealm" class="com.icinfo.relam.MyShiroRealm"><property name="userService" ref="userService"/></bean><!-- 会话验证调度器 --><!--<bean id="sessionValidationScheduler" class="com.icinfo.framework.security.shiro.quartz.QuartzSessionValidationScheduler">--><!--<property name="sessionValidationInterval" value="1800000"/>--><!--<property name="sessionManager" ref="defaultWebSessionManager"/>--><!--</bean>--><!--<bean id="defaultWebSessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">--><!--<property name="globalSessionTimeout" value="1800000"/>--><!--<property name="deleteInvalidSessions" value="true"/>--><!--<property name="sessionValidationSchedulerEnabled" value="true"/>--><!--<property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>--><!--<property name="sessionIdCookie.name" value="_hm_cid"/>--><!--<property name="sessionListeners">--><!--<list>--><!--<bean class="com.icinfo.framework.core.web.listener.CsrfTokenListener"/>--><!--</list>--><!--</property>--><!--</bean>--><bean class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
</beans>

2.5、web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version="3.0"><display-name>Archetype Created Web Application</display-name><!-- Spring和mybatis的配置文件 --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mybatis.xml</param-value></context-param><!-- 编码过滤器 --><filter><filter-name>encodingFilter</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><async-supported>true</async-supported><init-param><param-name>encoding</param-name><param-value>UTF-8</param-value></init-param></filter><filter-mapping><filter-name>encodingFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- Spring监听器 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- 防止Spring内存溢出监听器 --><listener><listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class></listener><!-- shiro config start --><filter><!-- 名称需要和spring-shiro-demo.xml中filter的名称相同 --><filter-name>shiroFilter</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class><init-param><param-name>targetFilterLifecycle</param-name><param-value>true</param-value></init-param></filter><filter-mapping><filter-name>shiroFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><!-- shiro config end--><!-- Spring MVC servlet --><servlet><servlet-name>SpringMVC</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-mvc.xml</param-value></init-param><load-on-startup>1</load-on-startup><async-supported>true</async-supported></servlet><servlet-mapping><servlet-name>SpringMVC</servlet-name><url-pattern>/</url-pattern></servlet-mapping>
</web-app>

2.6 login.jsp

<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head><title>登录页面</title>
</head>
<body>
<form id="form">用户名:<input type="input" name="username" id="username"/>密  码:<input type="input" name="password" id="password"/><input type="button" value="登录" id="submit"/>
</form>
</body>
<script src="/js/lib/jquery-1.12.3.min.js"></script>
<script src="/js/lib/jquery.serialize-object.min.js"></script>
<script src="/js/login.js"></script>
</html>

2.7 login.js

$(function () {$("#submit").click(function () {$.ajax({url:'/index/login',type:'post',dataType: 'json',data:$("#form").serializeObject(),success: function (json) {console.log(json);if(json.status=="success"){window.location.href = '/index';}else{alert(json.msg);}}})})
})

2.8、index.jsp

<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head><title>首页</title>
</head>
<body>
<div>登录成功。首页!
</div>
</body>
<script src="/js/lib/jquery-1.12.3.min.js"></script>
<script src="/js/lib/jquery.serialize-object.min.js"></script>
</html>

2.9、user_add.jsp

<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head><title>首页</title>
</head>
<body>
<div><h1>添加用户页面</h1><form id="form"><span style="display: inline-block;width: 80px;">用户名:</span><input type="text" name="username" id="name" autocomplete="new-password"/><br/><span style="display: inline-block;width: 80px;">密码:</span><input type="password" name="password" id="password" autocomplete="new-password"/><br/><span style="display: inline-block;width: 80px;">真实姓名:</span><input type="text" name="realname" id="realname" autocomplete="new-password"/><br/><input type="button" value="注册" id="submit" style="margin-left: 40px;"/><input type="reset" value="重置" /></form>
</div>
</body>
<script src="/js/lib/jquery-1.12.3.min.js"></script>
<script src="/js/lib/jquery.serialize-object.min.js"></script>
<script src="/js/user_add.js"></script>
</html>

2.10、user_add.js

$(function () {$("#submit").click(function () {$.ajax({url:'/user/add',type:'post',dataType: 'json',data:$("#form").serializeObject(),success: function (json) {console.log(json);alert(json.msg);if(json.status=="success"){$("#form").reset();}}})})
})

2.11、IndexController

package com.icinfo.controller;import com.icinfo.dto.LoginDto;
import com.icinfo.framework.common.ajax.AjaxResult;
import com.icinfo.model.User;
import com.icinfo.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;/**** @author fz* @create 2019-01-17 下午 5:46*/
@Controller
@RequestMapping("/index")
public class IndexController {@AutowiredUserService userService;@Value("${hashIterations}")String hashIterations;@Value("${algorithmName}")String algorithmName;Logger logger = LoggerFactory.getLogger(IndexController.class);/*** Description 访问登录页面* @param* @return org.springframework.web.servlet.ModelAndView* @throws Exception* @Author fz* @Date 2019-01-31 11:35:35*/@RequestMapping("/goLogin")public ModelAndView goLogin(){logger.info("---------------访问登录页面----------------");ModelAndView mav = new ModelAndView("login");return mav;}/*** Description 用户登录* @param* @return org.springframework.web.servlet.ModelAndView* @throws Exception* @Author fz* @Date 2019-01-31 11:35:35*/@RequestMapping("/login")@ResponseBodypublic AjaxResult login(HttpServletRequest request, HttpServletResponse response, LoginDto loginDto) throws Exception{if(loginDto == null || StringUtils.isBlank(loginDto.getUsername()) || StringUtils.isBlank(loginDto.getPassword())){return AjaxResult.error("用户名或密码不能为空");}User user = userService.findUserByUsername(loginDto.getUsername());if(user == null){return AjaxResult.error("用户名或密码不正确");}String password = new SimpleHash(algorithmName, loginDto.getPassword(), user.getSalt(), Integer.valueOf(hashIterations)).toHex();UsernamePasswordToken token = new UsernamePasswordToken(loginDto.getUsername(), password);Subject subject = SecurityUtils.getSubject();try{subject.login(token);}catch (Exception e){logger.info("登录失败,失败原因:[{}]", e.getMessage());e.printStackTrace();return AjaxResult.error("登录失败,请检查用户名和密码是否正确!");}return AjaxResult.success("success");}/*** 首页* @return* @throws Exception*/@RequestMappingpublic ModelAndView index() throws Exception{ModelAndView mav = new ModelAndView("index");return mav;}/*** 登出* @return* @throws Exception*/@RequestMapping("logout")public String logout() throws Exception{Subject subject = SecurityUtils.getSubject();if(subject.isAuthenticated()){subject.logout();}return "redirect:/index/goLogin";}
}

2.12、UserController

package com.icinfo.controller;import com.icinfo.framework.common.ajax.AjaxResult;
import com.icinfo.model.User;
import com.icinfo.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;/*** 用户控制器** @author fz* @create 2019-01-28 上午 10:58*/
@RequestMapping("/user")
@Controller
public class UserController {@AutowiredUserService userService;/*** Description 用户新增页面* @param* @return org.springframework.web.servlet.ModelAndView* @throws Exception* @Author fz* @Date 2019-01-31 11:33:24*/@RequestMapping("/userAddPage")public ModelAndView userAddPage() throws Exception{ModelAndView mav = new ModelAndView("user_add");return mav;}/*** Description 新增用户* @param* @return org.springframework.web.servlet.ModelAndView* @throws Exception* @Author fz* @Date 2019-01-31 11:33:24*/@RequestMapping("/add")@ResponseBodypublic AjaxResult addUser(User user) throws Exception{if(user == null || StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())){return AjaxResult.error("用户名和密码必须填写!");}try{userService.insertUser(user);}catch (Exception e){e.printStackTrace();return AjaxResult.error("创建系统用户失败!");}return AjaxResult.success("创建系统用户成功!");}
}

2.13、MyShiroRealm.java

package com.icinfo.relam;import com.icinfo.model.User;
import com.icinfo.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;import java.util.List;/*** @author fanzhen* @create 2019-01-08 下午 4:41*/
public class MyShiroRealm extends AuthorizingRealm {private UserService userService;@Overrideprotected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {return null;}/*** 获取验证信息* @param token* @return* @throws AuthenticationException*/@Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;if(StringUtils.isBlank(usernamePasswordToken.getUsername())){return null;}/*** 下面可以写自己的验证逻辑(因为是测试用例,简单验证下)*/User user = userService.findUserByUsername(usernamePasswordToken.getUsername());if(user == null){throw new AuthenticationException("用户信息认证失败");}SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(usernamePasswordToken.getUsername(), user.getPassword(), user.getRealname());info.setCredentialsSalt(ByteSource.Util.bytes(user.getSalt()));return info;}public UserService getUserService() {return userService;}public void setUserService(UserService userService) {this.userService = userService;}
}

2.14、UserService.java

package com.icinfo.service;
import com.icinfo.model.User;public interface UserService {/*** @Description 通过用户名查找用户* @author fz* @param username* @return*/User findUserByUsername(String username);/*** 插入用户* @author fz* @date 2019-01-30* @param user* @return*/int insertUser(User user) throws Exception;
}

2.15、UserServiceImpl.java(新增用户信息的代码)

package com.icinfo.service.impl;import com.icinfo.mapper.UserMapper;
import com.icinfo.model.User;
import com.icinfo.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
@Service("userService")
public class UserServiceImpl implements UserService {@AutowiredUserMapper userMapper;@Value("${hashIterations}")int hashIterations;@Value("${algorithmName}")String algorithmName;@Overridepublic User findUserByUsername(String username){if(StringUtils.isBlank(username)){return null;}return userMapper.findUserByUsername(username);}@Overridepublic int insertUser(User user) throws Exception {/*** 随机生成盐值*/String salt = new SecureRandomNumberGenerator().nextBytes().toHex();SimpleHash simpleHash = new SimpleHash(algorithmName, user.getPassword(), salt, hashIterations);user.setSalt(salt);user.setPassword(simpleHash.toHex());return userMapper.insertUser(user);}
}

2.16、UserMapper.java

package com.icinfo.mapper;import com.icinfo.model.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;@Repository("userMapper")
public interface UserMapper {User findUserByUsername(@Param("username") String username);/*** Description 插入数据* @param user* @return int* @throws Exception* @Author fz* @Date 2019-01-30 16:41:25*/int insertUser(User user);
}

2.17、UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.icinfo.mapper.UserMapper"><resultMap id="BaseResultMap" type="com.icinfo.model.User"><result property="id" column="id" jdbcType="INTEGER"/><result property="username" column="username" jdbcType="VARCHAR"/><result property="password" column="password" jdbcType="VARCHAR"/><result property="salt" column="salt" jdbcType="VARCHAR"/><result property="realname" column="realname" jdbcType="VARCHAR"/></resultMap><select id="findUserByUsername" parameterType="java.lang.String" resultMap="BaseResultMap">SELECT id, username, password, salt, realnameFROM USERWHERE 1=1<if test="username != null and username != ''">AND username = #{username}</if></select><insert id="insertUser" parameterType="com.icinfo.model.User">INSERT INTO USER(username,password,salt,realname) VALUES(#{username}, #{password}, #{salt}, #{realname})</insert>
</mapper>

3、实际操作:

3.1 新增用户

3.2 用户登录

3.2.1、用户登录

3.2.2、登录成功

Shiro+SSM+加盐登录简单示例相关推荐

  1. php如何每三位逗号分开,PHP 数字格式化,数字每三位加逗号的简单示例

    这篇文章主要为大家详细介绍了PHP 数字格式化,数字每三位加逗号的简单示例,具有一定的参考价值,可以用来参考一下. 对PHP数字格式化,数字每三位加逗号感兴趣的小伙伴,下面一起跟随512笔记的小编两巴 ...

  2. Unity5.X打包与加载AssetBundle简单示例

    准备与打包AssetBundle: 在Editor内,点击任意prefab或资源文件,在右下角(默认Editor布局)AssetsBundle处可设置此prefab的Assetsbundle属性. 例 ...

  3. 【密码学】轻松理解“加盐”的原理与java实现

    上一篇博客中说到防御彩虹表攻击最常用的方法就是加盐,那么什么是加盐呢? 一.什么是加盐? 1.背景 现在很多公司后台以hash值形式存储用户密码(虽然本文以MD5哈希函数为例,但becrypt函数最常 ...

  4. 【Shiro权限管理】10.Shiro为密码加盐

    上一篇我们提到了使用Shiro为密码进行MD5加密,这次来说一下密码加盐的问题. 当两个用户的密码相同时,单纯使用不加盐的MD5加密方式,会发现数据库中存在相同结构的密码, 这样也是不安全的.我们希望 ...

  5. Shiro认证及加盐加密

    目录 今天的知识是与上次所分享的知识相关联的,在Shiro入门的基础进行编写,上次之前的数据是死数据(放在Shiro.ini)而这次是活数据,可以连接到数据库,运用域Relam知识.同时出于维护用户的 ...

  6. 对于AES和RSA算法的结合使用以及MD5加盐注册登录时的密码加密

    RSA和AES结合使用 接上篇的RSA和AES算法加密之后,AES对称算法对数据量大的加密比较快,而RSA公私钥加密的话会影响加密效率,但是AES的加密与解密的密钥是一致的,导致密钥不能外泄,密钥在网 ...

  7. Java使用MD5加盐对密码进行加密处理,附注册和登录加密解密处理

    前言 在开发的时候,有一些敏感信息是不能直接通过明白直接保存到数据库的.最经典的就是密码了.如果直接把密码以明文的形式入库,不仅会泄露用户的隐私,对系统也是极其的不厉,这样做是非常危险的. 那么我们就 ...

  8. 关于Shiro使用密码加密加盐之后序列化失败的问题(十四)

    原文:https://blog.csdn.net/qq_34021712/article/details/84567437 shiro使用密码加盐之后,序列化失败 ERROR Failed to se ...

  9. 基于java注册登录MD5算法加盐加密颁发 Token身份令牌使用各种邮箱发送验证码详解雪花算法

    目的作用 == 在项目中,为了防止别人窥视我们的密码通常我们会采取一些加密方式.这里简单介绍一下MD5 加盐加密方法,MD5叫做信息-摘要算法,严格来说不是加密方式,而是信息摘要. 对于可以接触到数据 ...

最新文章

  1. 深度学习加速器堆栈Deep Learning Accelerator Stack
  2. 在Python-dataframe中如何把出生日期转化为年龄?
  3. 同一工作组无法访问_工作组,域
  4. virtualbox安装ubuntu时需要全屏显示的解决办法
  5. html支持的脚本语言,能不能让日志内容在支持html语言的同时支持一下脚本语言,拜托!拜托!...
  6. 《爱的博弈》(让婚姻持久保鲜的人际关系圣经)主要内容及大纲 免费下载
  7. matlab进行动力吸振器设计,动力吸振器详解.doc
  8. C语言求等腰梯形面积,几道C语言的题目!
  9. 基于百度翻译api的命令行翻译助手
  10. 第八章 配接器 adapters
  11. STM32串口中断接收一帧数据
  12. 电脑操作及相关指令、命令
  13. 三层HashMap的嵌套
  14. Shell | 文件或关键字查询
  15. 学生宿舍管理数据库设计(上)
  16. Vue-cli使用prerender-spa-plugin插件预渲染
  17. 11-27 概率论两种收敛方式
  18. 【前端基础】Vue学习笔记
  19. 一次奇怪的服务器响应延时分析
  20. SQL(MySQL)

热门文章

  1. python sort函数返回值_如何使用python sort函数?
  2. 使用 Gearman 实现分布式处理
  3. 中考计算机考试不合格会怎么样,初中小三科考试不及格对升高中有影响吗
  4. 优美文章 你住的城市下雨了
  5. numpy中argmax、argmin的用法
  6. 《极客时间-许健-技术管理案例课》读书笔记
  7. 银行柜员业务绩效考核系统的设计与实现(论文+源码)
  8. Java 天气预报WebService
  9. 原生JS实现下拉菜单操作
  10. dovecot 不用mysql_Dovecot无法执行mysql查询