当前位置: 首页>>代码示例>>Java>>正文


Java Hex.decode方法代码示例

本文整理汇总了Java中org.apache.shiro.codec.Hex.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Hex.decode方法的具体用法?Java Hex.decode怎么用?Java Hex.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.shiro.codec.Hex的用法示例。


在下文中一共展示了Hex.decode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCredentials

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
/**
 *
 * @param info the AuthenticationInfo from which to retrieve the credentials which assumed to be in already-hashed form.
 * @return a {@link Hash Hash} instance representing the given AuthenticationInfo's stored credentials.
 */
protected Object getCredentials(AuthenticationInfo info) {
    Object credentials = info.getCredentials();

    byte[] storedBytes = toBytes(credentials);

    if (credentials instanceof String || credentials instanceof char[]) {
        //account.credentials were a char[] or String, so
        //we need to do text decoding first:
        if (isStoredCredentialsHexEncoded()) {
            storedBytes = Hex.decode(storedBytes);
        } else {
            storedBytes = Base64.decode(storedBytes);
        }
    }
    AbstractHash hash = newHashInstance();
    hash.setBytes(storedBytes);
    return hash;
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:24,代码来源:HashedCredentialsMatcher.java

示例2: testHex

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
@Test
public void testHex(){
    String str = "hello";
    String hexEncode = Hex.encodeToString(str.getBytes());
    String str2 = new String(Hex.decode(hexEncode.getBytes()));
    Assert.assertEquals(str, str2);
}
 
开发者ID:l81893521,项目名称:shiro-demo,代码行数:8,代码来源:CodecAndCryptoTest.java

示例3: toBytes

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
protected byte[] toBytes(String sValue) {
    if (sValue == null) {
        return null;
    }
    byte[] bytes;
    if (sValue.startsWith(HEX_BEGIN_TOKEN)) {
        String hex = sValue.substring(HEX_BEGIN_TOKEN.length());
        bytes = Hex.decode(hex);
    } else {
        //assume base64 encoded:
        bytes = Base64.decode(sValue);
    }
    return bytes;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:15,代码来源:ReflectionBuilder.java

示例4: getCredentials

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
/**
 * Returns a {@link Hash Hash} instance representing the already-hashed AuthenticationInfo credentials stored in the system.
 * <p/>
 * This method reconstructs a {@link Hash Hash} instance based on a {@code info.getCredentials} call,
 * but it does <em>not</em> hash that value - it is expected that method call will return an already-hashed value.
 * <p/>
 * This implementation's reconstruction effort functions as follows:
 * <ol>
 * <li>Convert {@code account.getCredentials()} to a byte array via the {@link #toBytes toBytes} method.
 * <li>If {@code account.getCredentials()} was originally a String or char[] before {@code toBytes} was
 * called, check for encoding:
 * <li>If {@link #storedCredentialsHexEncoded storedCredentialsHexEncoded}, Hex decode that byte array, otherwise
 * Base64 decode the byte array</li>
 * <li>Set the byte[] array directly on the {@code Hash} implementation and return it.</li>
 * </ol>
 *
 * @param info the AuthenticationInfo from which to retrieve the credentials which assumed to be in already-hashed form.
 * @return a {@link Hash Hash} instance representing the given AuthenticationInfo's stored credentials.
 */
protected Object getCredentials(AuthenticationInfo info) {
    Object credentials = info.getCredentials();

    byte[] storedBytes = toBytes(credentials);

    if (credentials instanceof String || credentials instanceof char[]) {
        //account.credentials were a char[] or String, so
        //we need to do text decoding first:
        if (isStoredCredentialsHexEncoded()) {
            storedBytes = Hex.decode(storedBytes);
        } else {
            storedBytes = Base64.decode(storedBytes);
        }
    }
    AbstractHash hash = newHashInstance();
    hash.setBytes(storedBytes);
    return hash;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:38,代码来源:HashedCredentialsMatcher.java

示例5: getSecretKey

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
private byte[] getSecretKey() {
  return Hex.decode(getOrCreateConfiguration().getSecretKey());
}
 
开发者ID:obiba,项目名称:agate,代码行数:4,代码来源:ConfigurationService.java

示例6: getSecretKey

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
private byte[] getSecretKey() {
  return Hex.decode(getOrCreateMicaConfig().getSecretKey());
}
 
开发者ID:obiba,项目名称:mica2,代码行数:4,代码来源:MicaConfigService.java

示例7: decryptHex

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
/**
 * 16进制解密
 *
 * @param content
 * @return
 */
public static String decryptHex(String content) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(content), "消息摘要不能为空");
    return new String(Hex.decode(content));
}
 
开发者ID:melonlee,项目名称:LazyREST,代码行数:11,代码来源:EndecryptUtil.java

示例8: decryptHex

import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
/** 
 * 16进制解密 
 * @param cipherText 
 * @return 
 */ 
public static String decryptHex(String cipherText) { 
    return new String(Hex.decode(cipherText)); 
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:9,代码来源:EndecryptUtils.java


注:本文中的org.apache.shiro.codec.Hex.decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。