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

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

Introduction

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

Prototype

public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) 

Source Link

Document

Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.

Usage

From source file:com.images3.data.impl.ShortUUID.java

public static String randomUUID() {
    return new String(Base64.encodeBase64(toByteArray(UUID.randomUUID()), false, true)).toLowerCase();
}

From source file:com.jsmartframework.web.manager.AuthEncrypter.java

static String encrypt(HttpServletRequest request, String key, Object value) {
    if (key != null && value != null) {
        try {//from   w ww  .  jav  a 2 s .  c o m
            byte[] encode = getEncryptCipher(request, key).doFinal(value.toString().getBytes("UTF8"));
            return new String(Base64.encodeBase64(encode, true, true)).trim();
        } catch (Exception ex) {
            LOGGER.log(Level.INFO, "Failed to encrypt value [" + value + "]: " + ex.getMessage());
        }
        return value.toString();
    }
    return null;
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

static String encrypt(HttpServletRequest request, String value) {
    if (value != null) {
        try {//from  ww  w .j  a va  2s. c  om
            byte[] encode = getEncryptCipher(request).doFinal(value.getBytes("UTF8"));
            return new String(Base64.encodeBase64(encode, true, true)).trim();
        } catch (Exception ex) {
            LOGGER.log(Level.INFO, "Failed to encrypt tag [" + value + "]: " + ex.getMessage());
        }
    }
    return value;
}