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.archivas.clienttools.arcutils.utils.Base64Utils.java

public static byte[] decodeBuffer(String data) {
    byte[] result = null;

    if (data != null) {
        result = Base64.decodeBase64(data.getBytes());
    }/*from   ww  w .  j a  va 2  s.  c  om*/

    return result;
}

From source file:com.openbravo.pos.util.Base64Encoder.java

public static byte[] decode(String base64) {

    try {/*from  w  w w . j  a va  2 s. c o  m*/
        return Base64.decodeBase64(base64.getBytes("ASCII"));
    } catch (UnsupportedEncodingException e) {
        return null;
    }
}

From source file:com.bytecode.util.Crypto.java

public static String decrypt128(String key, String message) throws Exception {
    byte[] msg = Base64.decodeBase64(message);
    String decValue = new String(decrypt(key, msg, BITS128), "UTF-8");
    return decValue;
}

From source file:edu.lternet.pasta.client.Escalator.java

public static String addGroup(String token, String group) {

    String[] tokenParts = token.split("-");

    String authToken = new String(Base64.decodeBase64(tokenParts[0]));
    authToken += "*" + group;
    authToken = Base64.encodeBase64String(authToken.getBytes());

    return authToken + "-" + tokenParts[1];
}

From source file:com.agiletec.aps.util.DefaultApsEncrypter.java

public static String decrypt(String source) {
    try {// w  w  w . j a va 2 s . com
        Key key = getKey();
        Cipher desCipher = Cipher.getInstance(TRIPLE_DES);
        byte[] dec = Base64.decodeBase64(source.getBytes());
        desCipher.init(Cipher.DECRYPT_MODE, key);
        byte[] cleartext = desCipher.doFinal(dec);
        // Return the clear text
        return new String(cleartext);
    } catch (Throwable t) {
        throw new RuntimeException("Error decrypting string", t);
    }
}

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

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

From source file:com.hengyi.japp.tools.UuidUtils.java

public static String decodeBase64Uuid(String compressedUuid) {
    byte[] byUuid = Base64.decodeBase64(compressedUuid);
    ByteBuffer bb = ByteBuffer.wrap(byUuid);
    UUID uuid = new UUID(bb.getLong(), bb.getLong());
    return uuid.toString();
}

From source file:com.completetrsst.crypto.Common.java

/**
 * Converts a X509-encoded EC key to a PublicKey.
 *//*from   w w w  .j  a v a2 s  .  c  o m*/
public static PublicKey toPublicKeyFromX509(String stored) throws GeneralSecurityException {
    KeyFactory factory = KeyFactory.getInstance("EC");
    byte[] data = Base64.decodeBase64(stored);
    X509EncodedKeySpec spec = new X509EncodedKeySpec(data);
    return factory.generatePublic(spec);
}

From source file:com.roncoo.adminlte.util.Base64Util.java

/**
 * //from  w  w  w.j av a 2  s.c o m
 * 
 * @param key
 * @return
 */
public static String decode(String key) {
    byte[] dc = Base64.decodeBase64(key.getBytes());
    String dc_result = new String(dc).replaceAll("\r|\n", "");
    return dc_result;
}

From source file:com.honnix.yaacs.util.StringUtil.java

public static byte[] decodeBase64(String str) {
    byte[] decodedByteArray = null;

    try {//from w ww.  ja v a2  s . c  o  m
        decodedByteArray = Base64.decodeBase64(str.getBytes(UNDERLYING_CHARSET));
    } catch (UnsupportedEncodingException e) {
        // Should not happen.
        decodedByteArray = new byte[0];
    }

    return decodedByteArray;
}