Tabnine Logo
MD5EncryptUtil.encrypt
Code IndexAdd Tabnine to your IDE (free)

How to use
encrypt
method
in
cn.licoy.encryptbody.util.MD5EncryptUtil

Best Java code snippets using cn.licoy.encryptbody.util.MD5EncryptUtil.encrypt (Showing top 4 results out of 315)

origin: watchdog-framework/watchdog-framework

@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
  JwtToken jwtToken = (JwtToken) token;
  Object accountCredentials = getCredentials(info);
  if(jwtToken.getPassword()!=null){
    Object tokenCredentials = MD5EncryptUtil.encrypt(String.valueOf(
        jwtToken.getPassword())+jwtToken.getUsername());
    if(!accountCredentials.equals(tokenCredentials)){
      throw new DisabledAccountException("密码不正确!");
    }
  }else{
    boolean verify = JwtUtil.verify(jwtToken.getToken(), jwtToken.getUsername(), accountCredentials.toString());
    if(!verify){
      throw new DisabledAccountException("verifyFail");
    }
  }
  return true;
}
origin: watchdog-framework/watchdog-framework

  @Override
  public void resetPassword(ResetPasswordDTO resetPasswordDTO){
    SysUser user = this.selectById(resetPasswordDTO.getUid().trim());
    if(user==null){
      throw RequestException.fail(String.format("不存在ID为 %s 的用户",resetPasswordDTO.getUid()));
    }
    String password = MD5EncryptUtil.encrypt(String.valueOf(resetPasswordDTO.getPassword())+user.getUsername());
    user.setPassword(password);
    try {
      this.updateById(user);
      shiroService.clearAuthByUserId(user.getId(),true,true);
    }catch (Exception e){
      throw RequestException.fail(String.format("ID为 %s 的用户密码重置失败",resetPasswordDTO.getUid()),e);
    }
  }
}
origin: watchdog-framework/watchdog-framework

@Override
public void add(UserAddDTO addDTO) {
  SysUser findUser = this.findUserByName(addDTO.getUsername(),false);
  if(findUser!=null){
    throw RequestException.fail(
        String.format("已经存在用户名为 %s 的用户",addDTO.getUsername()));
  }
  try {
    findUser = new SysUser();
    BeanUtils.copyProperties(addDTO,findUser);
    findUser.setCreateDate(new Date());
    findUser.setPassword(MD5EncryptUtil.encrypt(String.valueOf(findUser.getPassword())+findUser.getUsername()));
    this.insert(findUser);
    this.updateUserRole(findUser);
  }catch (Exception e){
    throw RequestException.fail("添加用户失败",e);
  }
}
origin: Licoy/encrypt-body-spring-boot-starter

/**
 * 选择加密方式并进行加密
 * @param formatStringBody 目标加密字符串
 * @param infoBean 加密信息
 * @return 加密结果
 */
private String switchEncrypt(String formatStringBody,EncryptAnnotationInfoBean infoBean){
  EncryptBodyMethod method = infoBean.getEncryptBodyMethod();
  if(method==null){
    throw new EncryptMethodNotFoundException();
  }
  if(method == EncryptBodyMethod.MD5){
    return MD5EncryptUtil.encrypt(formatStringBody);
  }
  if(method == EncryptBodyMethod.SHA){
    SHAEncryptType shaEncryptType = infoBean.getShaEncryptType();
    if(shaEncryptType==null) shaEncryptType = SHAEncryptType.SHA256;
    return SHAEncryptUtil.encrypt(formatStringBody,shaEncryptType);
  }
  String key = infoBean.getKey();
  if(method == EncryptBodyMethod.DES){
    key = CheckUtils.checkAndGetKey(config.getAesKey(),key,"DES-KEY");
    return DESEncryptUtil.encrypt(formatStringBody,key);
  }
  if(method == EncryptBodyMethod.AES){
    key = CheckUtils.checkAndGetKey(config.getAesKey(),key,"AES-KEY");
    return AESEncryptUtil.encrypt(formatStringBody,key);
  }
  throw new EncryptBodyFailException();
}
cn.licoy.encryptbody.utilMD5EncryptUtilencrypt

Javadoc

MD5加密-32位小写

Popular methods of MD5EncryptUtil

    Popular in Java

    • Making http post requests using okhttp
    • onCreateOptionsMenu (Activity)
    • getSharedPreferences (Context)
    • addToBackStack (FragmentTransaction)
    • HttpURLConnection (java.net)
      An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
    • MessageDigest (java.security)
      Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
    • Map (java.util)
      A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
    • TimerTask (java.util)
      The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
    • Pattern (java.util.regex)
      Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
    • Reflections (org.reflections)
      Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
    • From CI to AI: The AI layer in your organization
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now