本文整理了Java中org.apache.shiro.crypto.hash.Hash.getAlgorithmName()
方法的一些代码示例,展示了Hash.getAlgorithmName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hash.getAlgorithmName()
方法的具体详情如下:
包路径:org.apache.shiro.crypto.hash.Hash
类名称:Hash
方法名:getAlgorithmName
[英]Returns the name of the algorithm used to hash the input source, for example, SHA-256, MD5, etc.
The name is expected to be a java.security.MessageDigest algorithm name.
[中]返回用于散列输入源的算法的名称,例如SHA-256、MD5等。
名称应为java。安全MessageDigest算法名称。
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!