当前位置:网站首页 > R语言数据分析 > 正文

springboot用户密码加密(spring boot 密码加密)



package com.learn.mall.service.impl; import com.learn.mall.exception.LearnMallException; import com.learn.mall.exception.LearnMallExceptionEnum; import com.learn.mall.model.dao.UserMapper; import com.learn.mall.model.pojo.User; import com.learn.mall.service.UserService; import com.learn.mall.util.MD5Utils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.security.NoSuchAlgorithmException; @Service public class UserServiceImpl implements UserService { @Autowired UserMapper userMapper;  @Override public void register(String username, String password) throws LearnMallException { //查询用户是否存在,不允许重名 User result = userMapper.selectByName(username); if (result != null) { throw new LearnMallException(LearnMallExceptionEnum.USERNAME_EXISTED); } //用户不存在,执行插入操作 User user = new User(); user.setUsername(username); //对密码进行MD5加密并加盐 try { user.setPassword(MD5Utils.getMD5Str(password)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } int count = userMapper.insertSelective(user); if(count == 0){ throw new LearnMallException(LearnMallExceptionEnum.INSERT_FAILED); } } }
到此这篇springboot用户密码加密(spring boot 密码加密)的文章就介绍到这了,更多相关 内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • Resnet101运行硬件要求(resnet101代码)2025-02-22 08:00:09
  • srore的中文翻译(sorcerer翻译)2025-02-22 08:00:09
  • treeworld破解版无限(treeagepro破解版)2025-02-22 08:00:09
  • resnet50和101哪个好(resnet50 101)2025-02-22 08:00:09
  • rang me up什么意思(rang up是什么意思)2025-02-22 08:00:09
  • neoterm更换国内源(fedora更换国内源)2025-02-22 08:00:09
  • redhatlinux虚拟机安装教程(虚拟机安装redhat6)2025-02-22 08:00:09
  • docker如何升级(docker 升级)2025-02-22 08:00:09
  • beyondcompare比较文件夹差异(beyondcompare对比文件夹)2025-02-22 08:00:09
  • tplease怎么读(tprtoise怎么读)2025-02-22 08:00:09
  • 全屏图片