List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64
public static byte[] decodeBase64(final byte[] base64Data)
From source file:com.evolveum.midpoint.util.SerializationUtil.java
public static <T> T fromString(String string) throws IOException, ClassNotFoundException { byte[] data = Base64.decodeBase64(string); ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(data)); Object object = objectInputStream.readObject(); objectInputStream.close();//from w w w . j a va2 s . c o m return (T) object; }
From source file:com.aliyun.oss.common.utils.BinaryUtil.java
public static byte[] fromBase64String(String base64String) { return Base64.decodeBase64(base64String); }
From source file:com.vico.license.util.rsa.RSAdoDecrypt.java
public static String decrypt(String cryptograph) throws Exception { Key privateKey;//from ww w. j a v a 2s . c om String path = Thread.currentThread().getContextClassLoader().getResource("/").toURI().getPath(); ObjectInputStream ois = null; try { /** ? */ ois = new ObjectInputStream(new FileInputStream(path + FileNames.PRIVATEKEY_NAME)); privateKey = (Key) ois.readObject(); } catch (Exception e) { throw e; } finally { ois.close(); } /** Cipher?RSA */ Cipher cipher = Cipher.getInstance(ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, privateKey); /** ? */ byte[] b1 = Base64.decodeBase64(cryptograph); /** ? */ byte[] b = cipher.doFinal(b1); return new String(b); }
From source file:de.qaware.chronix.storage.solr.converter.Util.java
/** * @param data the chunk of time series data as string (base64 encoded and zipped) * @return the points serialized to protocol buffers * @throws IOException if the data could not be processed *//*from w ww . j a v a 2s. c o m*/ public static ProtocolBuffer.Points loadIntoProtocolBuffers(String data) throws IOException { byte[] decoded = Base64.decodeBase64(data); return ProtocolBuffer.Points.parseFrom(Compression.decompressToStream(decoded)); }
From source file:at.supp.JsonTokenUtil2.java
public static String decodeFromBase64String(String encoded) { return new String(Base64.decodeBase64(encoded)); }
From source file:com.revolucion.secretwit.stego.URLSteganography.java
public static String decode(String text) { try {//from ww w . j a v a 2 s . c o m return new String(Base64.decodeBase64(text), DEFAULT_CHARSET); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:com.liferay.sync.engine.util.Encryptor.java
public static String decrypt(String value) throws Exception { if (value == null) { return ""; }/*ww w .ja va 2s . co m*/ SecretKey secretKey = new SecretKeySpec(_PASSWORD, _ALGORITHM); Cipher cipher = Cipher.getInstance(_ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, secretKey); String decryptedValue = value; for (int i = 0; i < _ITERATIONS; i++) { byte[] decodedBytes = Base64.decodeBase64(decryptedValue); byte[] decryptedBytes = cipher.doFinal(decodedBytes); decryptedValue = new String(decryptedBytes, _UTF8_CHARSET).substring(_SALT_LENGTH); } return decryptedValue; }
From source file:jp.or.openid.eiwg.scim.util.SCIMUtil.java
/** * BASE64/* www. j a v a 2 s . c o m*/ * * @param val ? * @return ? * @throws UnsupportedEncodingException * @throws Exception */ public static String decodeBase64(String val) throws IOException { // BASE64? val = val.replaceAll("[\n|\r]", ""); String decodeString = new String(Base64.decodeBase64(val), "UTF-8"); // ??????? String encodeString = encodeBase64(decodeString); if (encodeString.compareToIgnoreCase(val) != 0) { decodeString = ""; } // BASE64?? return decodeString; }
From source file:com.sysfore.pos.licensemanagement.LicenceManagementUtil.java
public static String decrypt(String strToDecrypt) { try {//from w ww . j a v a2s . co m Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.DECRYPT_MODE, secretKey); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt))); return decryptedString; } catch (Exception e) { log.error("Error while decrypting", e); } return null; }
From source file:com.mobicage.rogerthat.mfr.dal.Streamable.java
protected static Object fromBase64(String base64String) { try {/* w w w . j a v a 2s . c o m*/ ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decodeBase64(base64String)); try { ZipInputStream zip = new ZipInputStream(bis); try { zip.getNextEntry(); ObjectInput in = new ObjectInputStream(zip); try { return in.readObject(); } finally { in.close(); } } finally { zip.close(); } } finally { bis.close(); } } catch (ClassNotFoundException e) { log.log((Level.SEVERE), "ClassNotFoundException while deserializing member", e); return null; } catch (IOException e) { log.log((Level.SEVERE), "IOException while deserializing member", e); return null; } }