Example usage for org.apache.commons.codec.binary Hex decodeHex

List of usage examples for org.apache.commons.codec.binary Hex decodeHex

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Hex decodeHex.

Prototype

public static byte[] decodeHex(char[] data) throws IllegalArgumentException 

Source Link

Document

Converts an array of characters representing hexadecimal values into an array of bytes of those same values.

Usage

From source file:com.spectralogic.ds3client.utils.hashing.Md5Hash.java

public static Md5Hash fromHexString(final String hex) throws InvalidMd5Exception {
    try {//from w  w  w. j  a v a2s.c o m
        return new Md5Hash(Hex.decodeHex(hex.toCharArray()));
    } catch (final DecoderException e) {
        throw new InvalidMd5Exception(e);
    }
}

From source file:com.myb.portal.util.Encodes.java

/**
 * Hex?.//  ww w . jav  a  2s. co m
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        //         throw Exceptions.unchecked(e);
    }
    return null;
}

From source file:cn.hxh.springside.utils.EncodeUtils.java

/**
 * Hex?, String->byte[].//from   ww w .  ja  va 2  s .c  om
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new IllegalStateException("Hex Decoder exception", e);
    }
}

From source file:com.zimbra.cs.account.TokenUtil.java

public static Map<?, ?> getAttrs(String data) throws AuthTokenException {
    try {/* w  w  w .  ja  v  a 2  s.c  o m*/
        String decoded = new String(Hex.decodeHex(data.toCharArray()));
        return BlobMetaData.decode(decoded);
    } catch (DecoderException e) {
        throw new AuthTokenException("decoding exception", e);
    } catch (BlobMetaDataEncodingException e) {
        throw new AuthTokenException("blob decoding exception", e);
    }
}

From source file:com.streamsets.pipeline.lib.jdbc.parser.sql.RawTypeHandler.java

public static byte[] parseRaw(String column, String value, int columnType) throws StageException {
    if (value == null) {
        return null;
    }//from w w  w. j  a  v a 2  s.  com
    Matcher m = HEX_TO_RAW_PATTERN.matcher(value);
    if (m.find()) {
        try {
            return Hex.decodeHex(m.group(1).toCharArray());
        } catch (DecoderException e) {
            throw new StageException(JDBC_204, m.group(1));
        }
    }
    throw new UnsupportedFieldTypeException(column, value, columnType);
}

From source file:$.Encodes.java

/**
     * Hex?./*from w  w  w.ja v a  2  s. com*/
     */
    public static byte[] decodeHex(String input) {
        try {
            return Hex.decodeHex(input.toCharArray());
        } catch (DecoderException e) {
            throw Exceptions.unchecked(e);
        }
    }

From source file:com.idea.quickstart.common.security.Encodes.java

/**
 * Hex?.// w ww.  j  a va 2s. com
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        //ignore
    }
    return null;
}

From source file:cn.tonghao.remex.business.core.util.security.Encodes.java

/**
 * Hex?.//  w  w  w  .  j  ava2 s  .  c o  m
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.open.cas.shiro.util.EncodeUtils.java

/**
 * Hex?.//w  w  w  .  j a v  a2  s . c  om
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw ExceptionUtils.unchecked(e);
    }
}

From source file:com.topsem.common.utils.Encodes.java

/**
 * Hex?./* ww w . j  a  v  a  2 s  . c o  m*/
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw Throwables.propagate(e);
    }
}