本文整理了Java中org.apache.shiro.codec.Hex.decode()
方法的一些代码示例,展示了Hex.decode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hex.decode()
方法的具体详情如下:
包路径:org.apache.shiro.codec.Hex
类名称:Hex
方法名:decode
[英]Converts the specified Hex-encoded String into a raw byte array. This is a convenience method that merely delegates to #decode(char[]) using the argument's hex.toCharArray() value.
[中]将指定的十六进制编码字符串转换为原始字节数组。这是一种方便的方法,只需委托使用参数的十六进制进行#解码(char[])。toCharArray()值。
代码示例来源:origin: apache/shiro
/**
* Converts the specified Hex-encoded String into a raw byte array. This is a
* convenience method that merely delegates to {@link #decode(char[])} using the
* argument's hex.toCharArray() value.
*
* @param hex a Hex-encoded String.
* @return A byte array containing binary data decoded from the supplied String's char array.
*/
public static byte[] decode(String hex) {
return decode(hex.toCharArray());
}
代码示例来源:origin: Graylog2/graylog2-server
@Nullable
public static String decrypt(String cipherText, String encryptionKey, String salt) {
try {
@SuppressWarnings("CIPHER_INTEGRITY")
Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding", "SunJCE");
SecretKeySpec key = new SecretKeySpec(encryptionKey.getBytes("UTF-8"), "AES");
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(salt.getBytes("UTF-8")));
return new String(cipher.doFinal(Hex.decode(cipherText)), "UTF-8");
} catch (Exception e) {
LOG.error("Could not decrypt value.", e);
}
return null;
}
}
代码示例来源:origin: apache/shiro
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;
}
代码示例来源:origin: apache/shiro
/**
* Converts an array of character bytes representing hexadecimal values into an
* array of bytes of those same values. The returned array will be half the
* length of the passed array, as it takes two characters to represent any
* given byte. An exception is thrown if the passed char array has an odd
* number of elements.
*
* @param array An array of character bytes containing hexadecimal digits
* @return A byte array containing binary data decoded from
* the supplied byte array (representing characters).
* @throws IllegalArgumentException Thrown if an odd number of characters is supplied
* to this function
* @see #decode(char[])
*/
public static byte[] decode(byte[] array) throws IllegalArgumentException {
String s = CodecSupport.toString(array);
return decode(s);
}
代码示例来源:origin: apache/shiro
public static Md5Hash fromHexString(String hex) {
Md5Hash hash = new Md5Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
public static Sha256Hash fromHexString(String hex) {
Sha256Hash hash = new Sha256Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
public static Sha1Hash fromHexString(String hex) {
Sha1Hash hash = new Sha1Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
public static Sha512Hash fromHexString(String hex) {
Sha512Hash hash = new Sha512Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
public static Md2Hash fromHexString(String hex) {
Md2Hash hash = new Md2Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
public static Sha384Hash fromHexString(String hex) {
Sha384Hash hash = new Sha384Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: apache/shiro
bytes = Base64.decode(value);
} else {
bytes = Hex.decode(value);
代码示例来源:origin: apache/shiro
storedBytes = Hex.decode(storedBytes);
} else {
storedBytes = Base64.decode(storedBytes);
代码示例来源:origin: org.apache.shiro/shiro-core
storedBytes = Hex.decode(storedBytes);
} else {
storedBytes = Base64.decode(storedBytes);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro
/**
* Converts the specified Hex-encoded String into a raw byte array. This is a
* convenience method that merely delegates to {@link #decode(char[])} using the
* argument's hex.toCharArray() value.
*
* @param hex a Hex-encoded String.
* @return A byte array containing binary data decoded from the supplied String's char array.
*/
public static byte[] decode(String hex) {
return decode(hex.toCharArray());
}
代码示例来源:origin: org.apache.shiro/shiro-lang
/**
* Converts the specified Hex-encoded String into a raw byte array. This is a
* convenience method that merely delegates to {@link #decode(char[])} using the
* argument's hex.toCharArray() value.
*
* @param hex a Hex-encoded String.
* @return A byte array containing binary data decoded from the supplied String's char array.
*/
public static byte[] decode(String hex) {
return decode(hex.toCharArray());
}
代码示例来源:origin: org.apache.shiro/shiro-crypto-hash
public static Sha1Hash fromHexString(String hex) {
Sha1Hash hash = new Sha1Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro
public static Sha512Hash fromHexString(String hex) {
Sha512Hash hash = new Sha512Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro
public static Md2Hash fromHexString(String hex) {
Md2Hash hash = new Md2Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: org.apache.shiro/shiro-crypto-hash
public static Sha384Hash fromHexString(String hex) {
Sha384Hash hash = new Sha384Hash();
hash.setBytes(Hex.decode(hex));
return hash;
}
代码示例来源:origin: SomMeri/matasano-cryptopals-solutions
private boolean validate(String filename, String signature) {
byte[] expectedAuthentication = expectedSignature(filename);
byte[] clientAuthentication = Hex.decode(signature);
boolean isValid = insecureCompare(expectedAuthentication, clientAuthentication);
return isValid;
}
内容来源于网络,如有侵权,请联系作者删除!