Codota Logo
Encodes
Code IndexAdd Codota to your IDE (free)

How to use
Encodes
in
com.lcw.one.util.utils.cipher

Best Java code snippets using com.lcw.one.util.utils.cipher.Encodes (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: lcw2004/one

  @Override
  public boolean validatePassword(String plainPassword, String password) {
    byte[] salt = Encodes.decodeHex(password.substring(0, 16));
    byte[] hashPassword = DigestUtils.sha1(plainPassword.getBytes(), salt, PasswordUtils.HASH_INTERATIONS);
    return password.equals(Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword));
  }
}
origin: lcw2004/one

/**
 * 写数据到 response 中
 *
 * @param response
 * @param bytes       需要写入的字节数字
 * @param fileName    文件名称
 * @param contentType
 * @throws IOException
 */
public static void writeBytesToResponse(HttpServletResponse response, byte[] bytes, String fileName, String contentType) throws IOException {
  response.reset();
  response.setContentType(contentType);
  response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName));
  response.getOutputStream().write(bytes);
  response.getOutputStream().flush();
}
origin: lcw2004/one

/**
 * 认证回调函数, 登录时调用
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
  OneUsernamePasswordToken token = (OneUsernamePasswordToken) authcToken;
  // 如果登录失败超过3次需要验证码
  if (UserUtils.isNeedValidCode(token.getUsername())) {
    HttpServletRequest request = WebUtils.getHttpRequest(SecurityUtils.getSubject());
    String cookieValue = CookieUtils.getCookieValue(request);
    String validCode = getRedisUtil().get(cookieValue + "_" + VerifyCodeTypeEnum.LOGIN.getCode());
    if (token.getCaptcha() == null || !token.getCaptcha().toUpperCase().equals(validCode)) {
      throw new CaptchaException("验证码错误.");
    }
    getRedisUtil().remove(cookieValue + "_" + VerifyCodeTypeEnum.LOGIN.getCode());
  }
  UserInfoEO user = getUserService().getUserByLoginName(token.getUserType(), token.getUsername());
  if (user == null) {
    logger.info("用户不存在:UserName[{}], UserType[{}]", token.getUsername(), token.getUserType());
    return null;
  }
  if (StringUtils.isEmpty(user.getPassword())) {
    throw new OneBaseException("用户密码为空");
  }
  logger.info("用户登录:UserId[{}], Account[{}]", user.getUserId(), user.getAccount());
  byte[] salt = Encodes.decodeHex(user.getPassword().substring(0, 16));
  return new SimpleAuthenticationInfo(new Principal(user), user.getPassword().substring(16), ByteSource.Util.bytes(salt), getName());
}
origin: lcw2004/one

/**
 * 对字符串进行SHA1,并返回Hash值的16进制字符串
 * @param input
 * @return
 */
public static String sha1(String input) {
  return Encodes.encodeHex(sha1(input.getBytes()));
}
origin: lcw2004/one

@Override
public String encryptPassword(String plainPassword) {
  byte[] salt = RandomUtils.randomBytes(PasswordUtils.SALT_SIZE);
  byte[] hashPassword = DigestUtils.md5(plainPassword.getBytes(), salt, PasswordUtils.HASH_INTERATIONS);
  return Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword);
}
origin: lcw2004/one

  @Override
  public boolean validatePassword(String plainPassword, String password) {
    byte[] salt = Encodes.decodeHex(password.substring(0, 16));
    byte[] hashPassword = DigestUtils.md5(plainPassword.getBytes(), salt, PasswordUtils.HASH_INTERATIONS);
    return password.equals(Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword));
  }
}
origin: lcw2004/one

@ApiOperation("下载文件(内部)")
@GetMapping("/{fileId}/download")
public void downFile(HttpServletResponse response, @PathVariable String fileId, String fileName) {
  if (StringUtils.isEmpty(fileId)) {
    throw new OneBaseException("FileId不能为空");
  }
  SysFileEO sysFileEO = sysFileEOService.get(fileId);
  if (sysFileEO == null) {
    throw new OneBaseException("FileId[" + fileId + "]不存在");
  }
  try {
    if (StringUtils.isEmpty(fileName)) {
      fileName = sysFileEO.getFileName();
    }
    response.setHeader("Content-Disposition", "attachment; filename=" + Encodes.urlEncode(fileName + "." + sysFileEO.getFileType()));
    response.setContentType(sysFileEO.getContentType());
    fileStoreFactory.instance(sysFileEO.getStoreType()).loadFile(sysFileEO.getSavePath(), response.getOutputStream());
    response.getOutputStream().flush();
  } catch (IOException e) {
    logger.error(e.getMessage(), e);
    throw new OneBaseException("下载文件失败,请重试");
  }
}
origin: lcw2004/one

@Override
public String encryptPassword(String plainPassword) {
  byte[] salt = RandomUtils.randomBytes(PasswordUtils.SALT_SIZE);
  byte[] hashPassword = DigestUtils.sha1(plainPassword.getBytes(), salt, PasswordUtils.HASH_INTERATIONS);
  return Encodes.encodeHex(salt) + Encodes.encodeHex(hashPassword);
}
origin: lcw2004/one

/**
 * 对字符串进行MD5,并返回Hash值的16进制字符串
 * @param input
 * @return
 */
public static String md5(String input) {
  return Encodes.encodeHex(md5(input.getBytes()));
}
com.lcw.one.util.utils.cipherEncodes

Javadoc

封装各种格式的编码解码工具类. 1.Commons-Codec的 hex/base64 编码 2.自制的base62 编码 3.Commons-Lang的xml/html escape 4.JDK提供的URLEncoder

Most used methods

  • decodeHex
    Hex解码.
  • urlEncode
    URL 编码, Encode默认为UTF-8.
  • encodeHex
    Hex编码.

Popular in Java

  • Reactive rest calls using spring rest template
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • onCreateOptionsMenu (Activity)
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now