List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.bytecode.util.Crypto.java
public static String decrypt256(String key, String message) throws Exception { byte[] msg = Base64.decodeBase64(message); String decValue = new String(decrypt(key, msg, BITS256), "UTF-8"); return decValue; }
From source file:at.supp.JsonTokenUtil2.java
public static String fromBase64ToJsonString(String source) { return StringUtils.newStringUtf8(Base64.decodeBase64(source)); }
From source file:fi.aalto.seqpig.io.FastqStorer.java
@Override public void putNext(Tuple f) throws IOException { if (allFastqFieldNames == null) { try {//from w ww. ja v a2 s . c o m //BASE64Decoder decode = new BASE64Decoder(); Base64 codec = new Base64(); Properties p = UDFContext.getUDFContext().getUDFProperties(this.getClass()); String datastr = p.getProperty("allFastqFieldNames"); //byte[] buffer = decode.decodeBuffer(datastr); byte[] buffer = codec.decodeBase64(datastr); ByteArrayInputStream bstream = new ByteArrayInputStream(buffer); ObjectInputStream ostream = new ObjectInputStream(bstream); allFastqFieldNames = (HashMap<String, Integer>) ostream.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } } SequencedFragment fastqrec = new SequencedFragment(); int index; index = getFieldIndex("instrument", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setInstrument((String) f.get(index)); } index = getFieldIndex("run_number", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setRunNumber(((Integer) f.get(index))); } index = getFieldIndex("flow_cell_id", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setFlowcellId((String) f.get(index)); } index = getFieldIndex("lane", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setLane(((Integer) f.get(index))); } index = getFieldIndex("tile", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setTile(((Integer) f.get(index))); } index = getFieldIndex("xpos", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setXpos(((Integer) f.get(index))); } index = getFieldIndex("ypos", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setYpos(((Integer) f.get(index))); } index = getFieldIndex("read", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setRead(((Integer) f.get(index))); } index = getFieldIndex("qc_passed", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.BOOLEAN) { fastqrec.setFilterPassed(((Boolean) f.get(index))); } index = getFieldIndex("control_number", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setControlNumber(((Integer) f.get(index))); } index = getFieldIndex("index_sequence", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setIndexSequence((String) f.get(index)); } index = getFieldIndex("sequence", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setSequence(new Text((String) f.get(index))); } index = getFieldIndex("quality", allFastqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setQuality(new Text((String) f.get(index))); } try { writer.write(null, fastqrec); } catch (InterruptedException e) { throw new IOException(e); } }
From source file:fi.aalto.seqpig.io.QseqStorer.java
@Override public void putNext(Tuple f) throws IOException { if (allQseqFieldNames == null) { try {/*from w w w . j ava2 s. co m*/ //BASE64Decoder decode = new BASE64Decoder(); Base64 codec = new Base64(); Properties p = UDFContext.getUDFContext().getUDFProperties(this.getClass()); String datastr = p.getProperty("allQseqFieldNames"); //byte[] buffer = decode.decodeBuffer(datastr); byte[] buffer = codec.decodeBase64(datastr); ByteArrayInputStream bstream = new ByteArrayInputStream(buffer); ObjectInputStream ostream = new ObjectInputStream(bstream); allQseqFieldNames = (HashMap<String, Integer>) ostream.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } } SequencedFragment fastqrec = new SequencedFragment(); int index; index = getFieldIndex("instrument", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setInstrument((String) f.get(index)); } index = getFieldIndex("run_number", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setRunNumber(((Integer) f.get(index))); } index = getFieldIndex("flow_cell_id", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setFlowcellId((String) f.get(index)); } index = getFieldIndex("lane", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setLane(((Integer) f.get(index))); } index = getFieldIndex("tile", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setTile(((Integer) f.get(index))); } index = getFieldIndex("xpos", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setXpos(((Integer) f.get(index))); } index = getFieldIndex("ypos", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setYpos(((Integer) f.get(index))); } index = getFieldIndex("read", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setRead(((Integer) f.get(index))); } index = getFieldIndex("qc_passed", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.BOOLEAN) { fastqrec.setFilterPassed(((Boolean) f.get(index))); } index = getFieldIndex("control_number", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.INTEGER) { fastqrec.setControlNumber(((Integer) f.get(index))); } index = getFieldIndex("index_sequence", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setIndexSequence((String) f.get(index)); } index = getFieldIndex("sequence", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setSequence(new Text((String) f.get(index))); } index = getFieldIndex("quality", allQseqFieldNames); if (index > -1 && DataType.findType(f.get(index)) == DataType.CHARARRAY) { fastqrec.setQuality(new Text((String) f.get(index))); } try { writer.write(null, fastqrec); } catch (InterruptedException e) { throw new IOException(e); } }
From source file:com.opentok.util.Crypto.java
public static List<String> decodeSessionId(String sessionId) throws UnsupportedEncodingException { sessionId = sessionId.substring(2);//from w w w .j ava 2s. c o m sessionId = sessionId.replaceAll("-", "+").replaceAll("_", "/"); byte[] buffer = Base64.decodeBase64(sessionId); sessionId = new String(buffer, "UTF-8"); return new ArrayList<String>(Arrays.asList(sessionId.split("~"))); }
From source file:com.google.step2.util.EncodingUtil.java
public static byte[] decodeBase64(byte[] b64) { return Base64.decodeBase64(b64); }
From source file:com.security.ch08_rsa.RSACoderTextKey.java
/** * Decrypt data by private key// w ww . j a v a2s . c o m * @param data base64 encoded string * @param key base64 encoded string * @return decrypted string * @throws Exception */ public static String decryptByPrivateKey(String data, String key) throws Exception { byte[] result = decryptByPrivateKey(Base64.decodeBase64(data), Base64.decodeBase64(key)); return new String(result, UTF_8); }
From source file:it.unipmn.di.dcs.common.conversion.Convert.java
/** * Converts a Base64 string to a byte array. *//* w w w .ja v a2s . c o m*/ public static byte[] Base64ToBytes(String s) { if (s == null) { return null; } //return Base64.Decode( s ); // deprecated return Base64.decodeBase64(s.getBytes()); }
From source file:info.magnolia.cms.security.auth.Base64CallbackHandler.java
/** * @param credentials to be decoded// w w w . java2 s . c o m * @return String decoded credentials <b>name:password </b> */ private static String getDecodedCredentials(String credentials) { return (new String(Base64.decodeBase64(credentials.getBytes()))); }
From source file:com.searchbox.utils.DecryptLicense.java
public static boolean checkLicense(String lkey, String productName) { try {//from w w w . j a v a 2 s . com String licval = new String(decrypt(Base64.decodeBase64(lkey))); String[] lines = licval.split("\n"); boolean datecheck = checkDate(lines[1]); return datecheck & lines[2].contains(productName); } catch (Exception ex) { Logger.getLogger(DecryptLicense.class.getName()).log(Level.SEVERE, null, ex); } return false; }