org.apache.shiro.crypto.hash.Hash.getIterations()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(229)

本文整理了Java中org.apache.shiro.crypto.hash.Hash.getIterations()方法的一些代码示例,展示了Hash.getIterations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hash.getIterations()方法的具体详情如下:
包路径:org.apache.shiro.crypto.hash.Hash
类名称:Hash
方法名:getIterations

Hash.getIterations介绍

[英]Returns the number of hash iterations used to compute the hash.
[中]返回用于计算哈希的哈希迭代次数。

代码示例

代码示例来源:origin: apache/shiro

public String format(Hash hash) {
  if (hash == null) {
    return null;
  }
  String algorithmName = hash.getAlgorithmName();
  ByteSource salt = hash.getSalt();
  int iterations = hash.getIterations();
  StringBuilder sb = new StringBuilder(MCF_PREFIX).append(algorithmName).append(TOKEN_DELIMITER).append(iterations).append(TOKEN_DELIMITER);
  if (salt != null) {
    sb.append(salt.toBase64());
  }
  sb.append(TOKEN_DELIMITER);
  sb.append(hash.toBase64());
  return sb.toString();
}

代码示例来源:origin: apache/shiro

protected HashRequest buildHashRequest(ByteSource plaintext, Hash saved) {
  //keep everything from the saved hash except for the source:
  return new HashRequest.Builder().setSource(plaintext)
      //now use the existing saved data:
      .setAlgorithmName(saved.getAlgorithmName())
      .setSalt(saved.getSalt())
      .setIterations(saved.getIterations())
      .build();
}

代码示例来源:origin: magefree/mage

public AuthorizedUser(String name, Hash hash, String email) {
  this.name = name;
  this.password = hash.toBase64();
  this.salt = hash.getSalt().toBase64();
  this.hashAlgorithm = hash.getAlgorithmName();
  this.hashIterations = hash.getIterations();
  this.email = email;
  this.chatLockedUntil = null;
  this.active = true;
  this.lockedUntil = null;
}

代码示例来源:origin: org.apache.shiro/shiro-core

protected HashRequest buildHashRequest(ByteSource plaintext, Hash saved) {
  //keep everything from the saved hash except for the source:
  return new HashRequest.Builder().setSource(plaintext)
      //now use the existing saved data:
      .setAlgorithmName(saved.getAlgorithmName())
      .setSalt(saved.getSalt())
      .setIterations(saved.getIterations())
      .build();
}

代码示例来源:origin: org.apache.shiro/shiro-crypto-hash

public String format(Hash hash) {
  if (hash == null) {
    return null;
  }
  String algorithmName = hash.getAlgorithmName();
  ByteSource salt = hash.getSalt();
  int iterations = hash.getIterations();
  StringBuilder sb = new StringBuilder(MCF_PREFIX).append(algorithmName).append(TOKEN_DELIMITER).append(iterations).append(TOKEN_DELIMITER);
  if (salt != null) {
    sb.append(salt.toBase64());
  }
  sb.append(TOKEN_DELIMITER);
  sb.append(hash.toBase64());
  return sb.toString();
}

代码示例来源:origin: dschadow/JavaSecurity

private static Hash calculateHash(String password) {
  ByteSource privateSalt = ByteSource.Util.bytes(PRIVATE_SALT_BYTES);
  DefaultHashService hashService = new DefaultHashService();
  hashService.setPrivateSalt(privateSalt);
  hashService.setGeneratePublicSalt(true);
  hashService.setHashIterations(ITERATIONS);
  HashRequest.Builder builder = new HashRequest.Builder();
  builder.setSource(ByteSource.Util.bytes(password));
  Hash hash = hashService.computeHash(builder.build());
  log.info("Hash algorithm {}, iterations {}, public salt {}", hash.getAlgorithmName(), hash.getIterations(), hash.getSalt());
  return hash;
}

相关文章