本文整理汇总了Java中org.apache.shiro.crypto.hash.Hash.toHex方法的典型用法代码示例。如果您正苦于以下问题:Java Hash.toHex方法的具体用法?Java Hash.toHex怎么用?Java Hash.toHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.crypto.hash.Hash
的用法示例。
在下文中一共展示了Hash.toHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAuthenticationInfo
import org.apache.shiro.crypto.hash.Hash; //导入方法依赖的package包/类
@Override
protected AuthenticationInfo createAuthenticationInfo(AuthenticationToken token,
Object ldapPrincipal,
Object ldapCredentials, LdapContext ldapContext) throws NamingException {
HashRequest.Builder builder = new HashRequest.Builder();
Hash credentialsHash = hashService
.computeHash(builder.setSource(token.getCredentials())
.setAlgorithmName(HASHING_ALGORITHM).build());
return new SimpleAuthenticationInfo(token.getPrincipal(),
credentialsHash.toHex(), credentialsHash.getSalt(),
getName());
}
示例2: setPassword
import org.apache.shiro.crypto.hash.Hash; //导入方法依赖的package包/类
public void setPassword(ByteSource password, long minstolive) {
timeout = System.currentTimeMillis() + minstolive * 60 * 1000;
HashRequest request = new HashRequest.Builder()
.setSource(password)
.setSalt( getSalt() )
.build();
Hash hash = realm.getHashService().computeHash(request);
this.password = hash.toHex();
}
示例3: getHashedPassword
import org.apache.shiro.crypto.hash.Hash; //导入方法依赖的package包/类
public static String getHashedPassword(String password, String salt) {
Hash hash = new SimpleHash(hashAlgorithm, password, salt);
return hash.toHex();
}
示例4: format
import org.apache.shiro.crypto.hash.Hash; //导入方法依赖的package包/类
/**
* Returns {@code hash != null ? hash.toHex() : null}.
*
* @param hash the hash instance to format into a String.
* @return {@code hash != null ? hash.toHex() : null}.
*/
public String format(Hash hash) {
return hash != null ? hash.toHex() : null;
}
示例5: generateMD5HashValue
import org.apache.shiro.crypto.hash.Hash; //导入方法依赖的package包/类
/**
* 生成md5散列值
* @param password
* @param salt
* @return
*/
public static String generateMD5HashValue(String password, String salt) {
Hash hash = AuthenticatorUtils.generateHashValue("MD5", password, salt, 1);
return hash.toHex();//toString == toHex;there is anther method: toBase64
}