List of usage examples for org.apache.commons.codec.net BCodec encode
public Object encode(Object value) throws EncoderException
From source file:edu.harvard.iq.dvn.unf.Base64Encoding.java
/** * Alternative tobase64 method.Encodes the String(byte[]) instead of the array * * @param digest byte array for encoding in base 64, * @param cset String with name of charset * @return String base 64 the encoded base64 of digest *//*from w w w. j a va2s . c o m*/ public static String tobase641(byte[] digest, String cset) { byte[] revdigest = changeByteOrder(digest, ByteOrder.nativeOrder()); String str = null; str = new String(revdigest); ByteArrayOutputStream btstream = new ByteArrayOutputStream(); //this make sure is written in big-endian DataOutputStream stream = new DataOutputStream(btstream); String tobase64 = null; //use a charset for encoding if (cset == null) { cset = DEFAULT_CHAR_ENCODING; } BCodec bc = new BCodec(cset); try { tobase64 = (String) bc.encode(str); } catch (EncoderException err) { mLog.info("base64Encoding: exception" + err.getMessage()); } return tobase64; }
From source file:com.kwoksys.framework.util.StringUtils.java
/** * Encode a string to base64. Supports UTF8. * @return//from ww w . j a v a 2 s. c om */ public static String encodeBase64Codec(String input) { BCodec codec = new BCodec(); try { return codec.encode(input); } catch (EncoderException e) { logger.warning("Problem with base64 encoding."); return ""; } }
From source file:org.chenillekit.tapestry.core.components.Kaptcha.java
private Link getImageLink() { BCodec bCodec = new BCodec(); try {/* w ww.ja va2s .co m*/ return resources.createEventLink(EVENT_NAME, bCodec.encode(kaptchaProducer.createText())); } catch (EncoderException e) { throw new RuntimeException(e); } }