/** * Decodes a hexadecimal encoded string to raw bytes. * * @param encoded Hex encoded character data. * * @return Raw bytes of hex string. * * @throws EncodingException on decoding errors. */ public static byte[] hex(final CharSequence encoded) throws EncodingException { return decode(new HexDecoder(), encoded); }
/** * Decodes a base32-encoded string into raw bytes. * * @param encoded Base32-encoded character data. * * @return Base64-decoded bytes. * * @throws EncodingException on decoding errors. */ public static byte[] b32(final CharSequence encoded) throws EncodingException { return decode(new Base32Decoder(), encoded); }
/** * Decodes a base64-encoded string into raw bytes. * * @param encoded Base64-encoded character data. * * @return Base64-decoded bytes. * * @throws EncodingException on decoding errors. */ public static byte[] b64(final CharSequence encoded) throws EncodingException { return decode(new Base64Decoder(), encoded); }
/** * Compares a known hash value with the hash of the given data. * * @param hash Known encoded hash value. If the length of the hash bytes after decoding is greater than the length * of the digest output, anything beyond the digest length is considered salt data that is hashed * <strong>after</strong> the input data. * @param data Data to hash. * * @return True if the hashed data matches the given hash, false otherwise. * * @throws CryptoException on hash computation errors. * @throws EncodingException on encoding errors. * @throws StreamException on stream IO errors. */ @Override public boolean compare(final String hash, final Object... data) throws CryptoException, EncodingException, StreamException { return compareInternal(CodecUtil.decode(codecSpec.newInstance().getDecoder(), hash), data); } }