List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64String
public static String encodeBase64String(final byte[] binaryData)
From source file:com.open.cas.shiro.util.EncodeUtils.java
public static String base64md5(String input) { return Base64.encodeBase64String(DigestUtils.md5(input)); }
From source file:D_common.E_ncript.java
public static String encryptString(String strToEncrypt, String keyStr) { try {// w w w. ja v a 2 s .c o m return Base64.encodeBase64String(encrypt(strToEncrypt.getBytes(), keyStr)); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:eu.europa.ejusticeportal.dss.common.factory.SignedPDFFactory.java
/** * Create the signedPDF/* www . j a va2s. com*/ * * @param signedPdf the signedPDF as a byte array * @return the SignedPDF */ public static SignedPDF get(byte[] signedPdf) { return new SignedPDF(Base64.encodeBase64String(signedPdf)); }
From source file:com.calmio.calm.integration.Helpers.HTTPHandler.java
public static HTTPResponseData sendGet(String url, String username, String pwd) throws Exception { CloseableHttpClient client = HttpClients.custom() .setDefaultCredentialsProvider(getCredentialsProvider(url, username, pwd)).build(); int responseCode = 0; StringBuffer respo = null;// ww w . j av a 2 s . c o m String userPassword = username + ":" + pwd; // String encoding = Base64.getEncoder().encodeToString(userPassword.getBytes()); String encoding = Base64.encodeBase64String(userPassword.getBytes()); try { HttpGet request = new HttpGet(url); request.addHeader("Authorization", "Basic " + encoding); request.addHeader("User-Agent", USER_AGENT); System.out.println("Executing request " + request.getRequestLine()); CloseableHttpResponse response = client.execute(request); try { responseCode = response.getStatusLine().getStatusCode(); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); respo = new StringBuffer(); String inputLine; while ((inputLine = in.readLine()) != null) { respo.append(inputLine); } } finally { response.close(); } } finally { client.close(); } HTTPResponseData result = new HTTPResponseData(responseCode, ((respo == null) ? "" : respo.toString())); System.out.println(result.getStatusCode() + "/n" + result.getBody()); return result; }
From source file:com.kylinolap.rest.security.PasswordPlaceholderConfigurer.java
public static String encrypt(String strToEncrypt) { try {//from w w w . j a v a 2 s. co m Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); final SecretKeySpec secretKey = new SecretKeySpec(key, "AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); final String encryptedString = Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes())); return encryptedString; } catch (Exception e) { } return null; }
From source file:com.mirantis.cachemod.filter.HashedKeyProvider.java
@Override protected String shortQueryString(String queryString) { return Base64.encodeBase64String(digest(queryString)).replace('/', '_'); }
From source file:asia.stampy.common.serialization.SerializationUtils.java
/** * Serialize base64./*ww w .ja va 2 s. c o m*/ * * @param o * the o * @return the string * @throws IOException * Signals that an I/O exception has occurred. */ public static String serializeBase64(Object o) throws IOException { SERIALIZE_LOCK.lock(); try { if (o instanceof byte[]) return Base64.encodeBase64String((byte[]) o); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o); return Base64.encodeBase64String(baos.toByteArray()); } finally { SERIALIZE_LOCK.unlock(); } }
From source file:com.example.license.RSAUtil.java
/** * ?// w w w . j a va 2 s . co m * * @param data * ? * @param key * * @return ?? */ public static String encrypt(String data, String seed) throws Exception { KeyPair keyPair = generatorKeyPair(seed); // Cipher?? Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); // SecureRandom random = new SecureRandom(); // ?Cipher? cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPrivate()); byte[] results = cipher.doFinal(data.getBytes()); // http://tripledes.online-domain-tools.com/?? for (int i = 0; i < results.length; i++) { System.out.print(results[i] + " "); } System.out.println(); // ??Base64? return Base64.encodeBase64String(results); }
From source file:edu.wright.cs.sp16.ceg3120.util.PasswordEncryptionUtility.java
/** * Encrypts a given string using AES./*from w w w . j av a 2 s. c o m*/ * * @param value * // String to encrypt. * @return // Returns encrypted string. */ public static String encrypt(String value) { try { IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); byte[] encrypted = cipher.doFinal(value.getBytes("UTF-8")); System.out.println("encrypted string: " + Base64.encodeBase64String(encrypted)); return Base64.encodeBase64String(encrypted); } catch (RuntimeException e) { throw e; } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:com.eviware.loadui.util.serialization.SerializationUtils.java
public static String serializeBase64(Object object) throws IOException { if (object == null) return null; return Base64.encodeBase64String(serialize(object)); }