Example usage for org.apache.commons.codec.binary Base64 decodeBase64

List of usage examples for org.apache.commons.codec.binary Base64 decodeBase64

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Base64 decodeBase64.

Prototype

public static byte[] decodeBase64(final byte[] base64Data) 

Source Link

Document

Decodes Base64 data into octets

Usage

From source file:com.opentok.test.Helpers.java

public static Map<String, String> decodeToken(String token) throws UnsupportedEncodingException {
    Map<String, String> tokenData = new HashMap<String, String>();
    token = token.substring(4);/*from   w w w.ja  v  a 2  s  .  co  m*/
    byte[] buffer = Base64.decodeBase64(token);
    String decoded = new String(buffer, "UTF-8");
    String[] decodedParts = decoded.split(":");
    for (String part : decodedParts) {
        tokenData.putAll(decodeFormData(part));
    }
    return tokenData;
}

From source file:com.reydentx.core.common.PhotoUtils.java

public static byte[] fromBlobString(String blobImage) {
    if (blobImage.startsWith("data:image")) {
        String imgData = blobImage.substring(blobImage.indexOf(",") + 1, blobImage.length()) + "";
        return Base64.decodeBase64(imgData);
    }/*from   w  w  w . j  av a 2s .co m*/

    return null;
}

From source file:de.pawlidi.openaletheia.utils.Converter.java

public static byte[] toBytes(String string) {
    return Base64.decodeBase64(string);
}

From source file:Main.java

public static ByteBuffer getServiceDataFromEnv(String serviceName, Map<String, String> env) {
    String meta = env.get(getPrefixServiceName(serviceName));
    if (null == meta) {
        return null;
    }/*from  w ww  . java  2  s  .  c  om*/
    byte[] metaData = Base64.decodeBase64(meta);
    return ByteBuffer.wrap(metaData);
}

From source file:com.fruit.core.util.MyDigestUtils.java

public static String decode64(String str) {
    try {/*from  w ww  .  j  a va 2  s .c  om*/
        return new String(Base64.decodeBase64(str), "utf-8");
    } catch (UnsupportedEncodingException e) {
    }
    return new String(Base64.decodeBase64(str));
}

From source file:Logic.security.java

public static String symmetricDecrypt(String text, String secretKey) {
    Cipher cipher;//from  w  w w.j a v a  2 s. c  om
    String encryptedString;
    byte[] encryptText = null;
    byte[] raw;
    SecretKeySpec skeySpec;
    try {
        raw = Base64.decodeBase64(secretKey);
        skeySpec = new SecretKeySpec(raw, "AES");
        encryptText = Base64.decodeBase64(text);
        cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.DECRYPT_MODE, skeySpec);
        encryptedString = new String(cipher.doFinal(encryptText));
    } catch (Exception e) {
        e.printStackTrace();
        return "Error";
    }
    return encryptedString;
}

From source file:com.duy.pascal.ui.purchase.StringXor.java

@NonNull
public static String decode(String s) {
    return new String((Base64.decodeBase64(s.getBytes())));
}

From source file:encryptdecrypt.util.Security.java

public static String decrypt(String strToDecrypt) {
    try {/*from   w  ww  .j a va 2 s. c  o m*/
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
        final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
        cipher.init(Cipher.DECRYPT_MODE, secretKey);
        return new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes())));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.main.mailer.UploadPdf.java

public static byte[] decodeImage(String imageDataString) {
    return Base64.decodeBase64(imageDataString);
}

From source file:jp.primecloud.auto.api.ApiFilter.java

/**
 *
 * BASE64??LinkedHashMap??// ww w  .  ja  va  2s  . c  o  m
 * ?BASE64
 *
 * @param url URL
 * @return LinkedHashMap<??, >
 * @throws UnsupportedEncodingException
 */
@SuppressWarnings("static-access")
private LinkedHashMap<String, String> getDecodedParamMap(URI uri) throws UnsupportedEncodingException {
    LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
    String queryUrlText = uri.getQuery();
    if (StringUtils.isNotEmpty(queryUrlText)) {
        try {
            Base64 base64 = new Base64(true);
            String decodedUri = new String(base64.decodeBase64(queryUrlText.getBytes("UTF-8")), "UTF-8");
            for (String param : decodedUri.split("&")) {
                String key = param.substring(0, param.indexOf("="));
                String value = param.substring(param.indexOf("=") + 1, param.length());
                if (PARAM_NAME_SIGNATURE.equals(key)) {
                    map.put(key, value);
                } else {
                    map.put(key, value);
                }
            }
        } catch (Exception e) {
            throw new AutoApplicationException("EAPI-000008", e, "URL", uri.toString());
        }
    }
    return map;
}