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

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

Introduction

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

Prototype

public static String encodeBase64URLSafeString(final byte[] binaryData) 

Source Link

Document

Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output.

Usage

From source file:mvm.rya.indexing.accumulo.Md5Hash.java

public static String md5Base64(byte[] data) {
    return Base64.encodeBase64URLSafeString(DigestUtils.md5(data));
}

From source file:com.bjwg.back.util.EncodeUtils.java

public static String encodeUrlSafeBase64(byte[] input) {
    return Base64.encodeBase64URLSafeString(input);
}

From source file:io.milton.http.http11.auth.HmacUtils.java

public static String calcShaHash(String data, String key) {
    String result = null;//from   w  w  w .ja va 2  s  .  com
    try {
        Key signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
        Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
        mac.init(signingKey);
        byte[] rawHmac = mac.doFinal(data.getBytes());
        result = Base64.encodeBase64URLSafeString(rawHmac);
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(HMAC_SHA1_ALGORITHM, e);
    } catch (InvalidKeyException e) {
        throw new RuntimeException(HMAC_SHA1_ALGORITHM, e);
    } catch (IllegalStateException e) {
        throw new RuntimeException(HMAC_SHA1_ALGORITHM, e);
    }

    return result;
}

From source file:jp.ac.tokushima_u.is.ll.util.EncodeUtils.java

/**
 * Base64?, URL(URL??+,/,=, ?RFC3548)./*  ww w.j ava 2 s . c  om*/
 */
public static String base64UrlEncode(byte[] input) {
    return Base64.encodeBase64URLSafeString(input);
}

From source file:de.fhdo.helper.DES.java

public static String encrypt(String Text) {
    try {/*from   w  ww  .j  a  v a  2 s  .c o  m*/
        DESKeySpec keySpec = new DESKeySpec("schluessel_stdrepository15".getBytes("UTF8"));
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey key = keyFactory.generateSecret(keySpec);

        // ENCODE plainTextPassword String
        byte[] cleartext = Text.getBytes("UTF8");
        Cipher cipher = Cipher.getInstance("DES");
        // cipher is not thread safe
        cipher.init(Cipher.ENCRYPT_MODE, key);
        return Base64.encodeBase64URLSafeString(cipher.doFinal(cleartext));

    } catch (Exception e) {
        e.printStackTrace();
    }

    return "";
}

From source file:com.streamsets.pipeline.lib.el.Base64EL.java

@ElFunction(prefix = "base64", name = "encodeBytes", description = "Returns base64 encoded version of the string argument.")
public static String base64Encode(@ElParam("string") byte[] bytes, @ElParam("urlSafe") boolean urlSafe) {
    if (urlSafe) {
        return Base64.encodeBase64URLSafeString(bytes);
    } else {/*from  ww  w .java2 s  . c o  m*/
        return Base64.encodeBase64String(bytes);
    }
}

From source file:cn.newtouch.util.utils.encode.EncodeUtils.java

/**
 * Base64?, URL(Base64URL?+,/=, ?RFC3548).
 *///from  w  w  w. j av  a 2  s.  c  om
public static String base64UrlSafeEncode(byte[] input) {
    return Base64.encodeBase64URLSafeString(input);
}

From source file:com.apabi.qrcode.utils.EncodeUtils.java

/**
 * Base64?, URL(Base64URL?+,/=, ?RFC3548).
 *//* w  w w . j a  va  2 s  .  co m*/
public static String base64UrlSafeEncode(final byte[] input) {
    return Base64.encodeBase64URLSafeString(input);
}

From source file:apm.common.utils.Encodes.java

/**
 * Base64?, URL(Base64URL?'+''/''-''_', ?RFC3548).
 *///from  w w w.  j a  v  a 2  s. co m
public static String encodeUrlSafeBase64(byte[] input) {
    return Base64.encodeBase64URLSafeString(input);
}

From source file:com.akshffeen.utils.Base64Image.java

/**
 * Encodes the byte array into base64 string
 * @param imageByteArray - byte array/*from  w  w w. j a  v a  2 s.c om*/
 * @return String a {@link java.lang.String}
 */
public static String encodeImage(byte[] imageByteArray) {
    return Base64.encodeBase64URLSafeString(imageByteArray);
}