/** * This is a wrapper to <code>decode(final byte[] code, final int from, final int len)</code> * @param code * @return a byte array holding encoded char data */ public final static byte[] decode(final byte[] code) { return decode(code, 0, code.length); }
/** * @param text * @return encoded text */ public final static byte[] encode(final byte[] text) { return encode(text, 0, text.length); }
/** This is a wrapper to <code>toCharArray(final byte[] text, final int from, final int len)</code> * @param text * @return an encoded char array from the text */ public final static char[] toCharArray(final byte[] text) { return toCharArray(text, 0, text.length); }
str = new String(Base64.encode(shortToByte(data))); time = System.nanoTime() - start; System.out.println("encoding to base64 took "+(time/1000000)+" milliseconds"); data2 = byteToshort(Base64.decode(str.getBytes())); time = System.nanoTime() - start; System.out.println("decoding base64 took "+(time/1000000)+" milliseconds");
/** * @param code * @return the decoded array */ public final static byte[] decodeFailSafe(char[] code) { return decodeFailSafe(code, 0, code.length); }
/** * <code>decodeCRLF(code, 0, code.length, 76)</code> * @param code * @return the encoded text; */ public final static byte[] decode76(final char[] code) { return decodeCRLF(code, 0, code.length, 76); }
public String convertObject(Object val, Object context) { byte[] bytes = Base64.encode((byte[])val); return new String(bytes); } };
/** This is a wrapper to <code>decode(final char[] code, final int from, final int len)</code> * @param code * @return a byte array holding encoded char data */ public final static byte[] decode(final char[] code) { return decode(code, 0, code.length); }
public String execute(byte[] args) { String id = new String(Base64.toCharArray(args)); return id; } };
public String convertObject(Object val, Object context) { return new String(Base64.encode(new byte[]{((Byte)val).byteValue()})); } };
public Object convertString(String val, Object context) { return Base64.decode(val.getBytes()); } };
public String execute(byte[] args) { String id = new String(Base64.toCharArray(args)); // String id = new String(args, SUtil.ASCII); return id; } };
/** * Get the data as a transferable string. * @return the data string. */ public String getDataString() { String ret = null; if(data!=null) { ret = new String(Base64.encode(data), Charset.forName("UTF-8")); } return ret; }
/** * Set the data. * @param data The data to set. */ public void setDataString(String sdata) { this.data = Base64.decode(sdata.getBytes(Charset.forName("UTF-8"))); }
/** * Get the textual representation of a certificate. */ public static String getCertificateText(Certificate cert) { String ret = null; try { StringBuffer buf = new StringBuffer("-----BEGIN CERTIFICATE-----").append(SUtil.LF); buf.append(new String(Base64.toCharArray(cert.getEncoded(), 64))); buf.append(SUtil.LF).append("-----END CERTIFICATE-----"); ret = buf.toString(); } catch(Exception e) { throw new RuntimeException(e); } return ret; }
public String convertObject(Object val, Object context) { try { byte[] buf = SGUI.imageToStandardBytes((Image) val, "image/png"); return new String(Base64.encode(buf)); } catch (Exception e) { // todo: use context report throw new RuntimeException(e); } } };
default: return decode(code, from, cj - from);
/** * Get the data as a transferable string. * * @return the data string. */ public String getDataString() { String ret = null; if(data!=null) { ret = new String(Base64.encode(ArrayTest.shortToByte(data))); } return ret; }
public Object createObject(IContext context, Map rawattributes) throws Exception { byte[] bytes = Base64.decode(((String)rawattributes.get("content")).getBytes(Charset.forName("UTF-8"))); return Byte.valueOf(bytes[0]); } }),
ret = new String(Base64.encode(baos.toByteArray()), "UTF-8");