/** * Decodes the given base 32 encoded string, * skipping carriage returns, line feeds and spaces as needed. */ public static byte[] decode(String b32) { if (b32 == null) return null; if (b32.length() == 0) return new byte[0]; byte[] buf = new byte[b32.length()]; int len = CodecUtils.sanitize(b32, buf); return codec.decode(buf, len); }
sanityCheckLastPos(p, MASK_4BITS); return; sanityCheckLastPos(p, MASK_2BITS); return;
Base16Codec(boolean upperCase) { this.alphabets = upperCase ? CodecUtils.toBytesDirect("0123456789ABCDEF") : CodecUtils.toBytesDirect("0123456789abcdef"); }
/** * Returns a base 16 encoded string (in upper case) of the given bytes. */ public static String encodeAsString(byte ... bytes) { if (bytes == null) return null; return bytes.length == 0 ? "" : CodecUtils.toStringDirect(codec.encode(bytes)); }
/** * Returns a base 32 encoded string of the given bytes. */ public static String encodeAsString(byte ... bytes) { if (bytes == null) return null; return bytes.length == 0 ? "" : CodecUtils.toStringDirect(codec.encode(bytes)); }
/** * Returns a base 16 encoded string (in lower case) of the given bytes. */ public static String encodeAsString(byte ... bytes) { if (bytes == null) return null; return bytes.length == 0 ? "" : CodecUtils.toStringDirect(codec.encode(bytes)); }
/** * Decodes the given base 16 encoded string, * skipping carriage returns, line feeds and spaces as needed. */ public static byte[] decode(String b16) { if (b16 == null) return null; if (b16.length() == 0) return new byte[0]; byte[] buf = new byte[b16.length()]; int len = CodecUtils.sanitize(b16, buf); return codec.decode(buf, len); }
Base64Codec() { this.alphabets = CodecUtils.toBytesDirect("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); }
sanityCheckLastPos(p, MASK_2BITS); return; sanityCheckLastPos(p, MASK_4BITS); return; sanityCheckLastPos(p, 1); return; sanityCheckLastPos(p, MASK_3BITS); return;
/** * Returns a base 64 encoded string of the given bytes. */ public static String encodeAsString(byte... bytes) { if (bytes == null) { return null; } if (isJaxbAvailable) { try { return DatatypeConverter.printBase64Binary(bytes); } catch (NullPointerException ex) { // https://netbeans.org/bugzilla/show_bug.cgi?id=224923 // https://issues.apache.org/jira/browse/CAMEL-4893 // Note the converter should eventually be initialized and printBase64Binary should start working again LOG.debug("Recovering from JAXB bug: https://netbeans.org/bugzilla/show_bug.cgi?id=224923", ex); } } return bytes.length == 0 ? "" : CodecUtils.toStringDirect(codec.encode(bytes)); }
/** * Decodes the given base 16 encoded string, * skipping carriage returns, line feeds and spaces as needed. */ public static byte[] decode(String b16) { if (b16 == null) return null; if (b16.length() == 0) return new byte[0]; byte[] buf = new byte[b16.length()]; int len = CodecUtils.sanitize(b16, buf); return codec.decode(buf, len); }
private static byte[] alphabets() { // Base 32 alphabet as defined at http://www.ietf.org/rfc/rfc4648.txt return CodecUtils.toBytesDirect("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); }
sanityCheckLastPos(p, MASK_4BITS); return; sanityCheckLastPos(p, MASK_2BITS); return;
/** * @param bytes the bytes. * @return a base 64 encoded string of the given bytes. */ public static String encodeAsString(byte... bytes) { if (bytes == null) return null; return bytes.length == 0 ? "" : CodecUtils.toStringDirect(CODEC.encode(bytes)); }
/** * Decodes the given base 64 encoded string, * skipping carriage returns, line feeds and spaces as needed. */ public static byte[] decode(String b64) { if (b64 == null) { return null; } if (b64.length() == 0) { return new byte[0]; } byte[] buf = new byte[b64.length()]; int len = CodecUtils.sanitize(b64, buf); return codec.decode(buf, len); }
Base16Codec(boolean upperCase) { this.alphabets = upperCase ? CodecUtils.toBytesDirect("0123456789ABCDEF") : CodecUtils.toBytesDirect("0123456789abcdef"); }
sanityCheckLastPos(p, MASK_4BITS); return; sanityCheckLastPos(p, MASK_2BITS); return;
/** * @param bytes the bytes. * @return a base 16 encoded string of the given bytes. */ public static String encodeAsString(byte... bytes) { if (bytes == null) return null; return bytes.length == 0 ? "" : CodecUtils.toStringDirect(CODEC.encode(bytes)); }
/** * Decodes the given base 16 encoded string, * skipping carriage returns, line feeds and spaces as needed. */ public static byte[] decode(String b16) { if (b16 == null) return null; if (b16.length() == 0) return new byte[0]; byte[] buf = new byte[b16.length()]; int len = CodecUtils.sanitize(b16, buf); return codec.decode(buf, len); }
private static byte[] alphabets() { // Base 32 alphabet as defined at http://www.ietf.org/rfc/rfc4648.txt return CodecUtils.toBytesDirect("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"); }