/** * Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. * * @param pArray * a byte array containing binary data * @return A byte array containing only the base N alphabetic character data */ @Override public byte[] encode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } return encode(pArray, 0, pArray.length); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. * @since 1.5 * This is a duplicate of {@link #encodeToString(byte[])}; it was merged during refactoring. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Writes EOF. * * @throws IOException * if an I/O error occurs. * @since 1.11 */ public void eof() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } }
/** * Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of * the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[]. * * @param obj * Object to encode * @return An object (of type byte[]) containing the Base-N encoded data which corresponds to the byte[] supplied. * @throws EncoderException * if the parameter supplied is not of type byte[] */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof byte[])) { throw new EncoderException("Parameter supplied to Base-N encode is not a byte[]"); } return encode((byte[]) obj); }
/** * Encodes a byte[] containing binary data, into a byte[] containing * characters in the alphabet. * * @param pArray * a byte array containing binary data * @param offset * initial offset of the subarray. * @param length * length of the subarray. * @return A byte array containing only the base N alphabetic character data * @since 1.11 */ public byte[] encode(final byte[] pArray, final int offset, final int length) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); encode(pArray, offset, length, context); encode(pArray, offset, EOF, context); // Notify encoder of EOF. final byte[] buf = new byte[context.pos - context.readPos]; readResults(buf, 0, buf.length, context); return buf; }
/** * Returns an encoded and decoded copy of the same random data. * * @param codec the codec to use * @param size amount of random data to generate and encode * @return two byte[] arrays: [0] = decoded, [1] = encoded */ static byte[][] randomData(final BaseNCodec codec, final int size) { final Random r = new Random(); final byte[] decoded = new byte[size]; r.nextBytes(decoded); final byte[] encoded = codec.encode(decoded); return new byte[][] {decoded, encoded}; }
} else if (len > 0) { if (doEncode) { baseNCodec.encode(b, offset, len, context); } else { baseNCodec.decode(b, offset, len, context);
final int c = in.read(buf); if (doEncode) { baseNCodec.encode(buf, 0, c, context); } else { baseNCodec.decode(buf, 0, c, context);
/** * Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. * * @param pArray * a byte array containing binary data * @return A byte array containing only the base N alphabetic character data */ @Override public byte[] encode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } return encode(pArray, 0, pArray.length); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. * @since 1.5 * This is a duplicate of {@link #encodeToString(byte[])}; it was merged during refactoring. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); }