本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例5: getSecretKey
import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
private byte[] getSecretKey() {
return Hex.decode(getOrCreateConfiguration().getSecretKey());
}
示例6: getSecretKey
import org.apache.shiro.codec.Hex; //导入方法依赖的package包/类
private byte[] getSecretKey() {
return Hex.decode(getOrCreateMicaConfig().getSecretKey());
}
示例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));
}
示例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));
}