List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64String
public static String encodeBase64String(final byte[] binaryData)
From source file:com.aqnote.shared.cryptology.cert.tool.X509CertTool.java
public static String coverCert2String(Certificate cert) throws CertificateEncodingException { String certContent = Base64.encodeBase64String(cert.getEncoded()); String crtFile = BEGIN_CERT + lineSeparator + certContent + END_CERT; return crtFile; }
From source file:de.qaware.chronix.storage.solr.converter.Util.java
/** * @param data the data points that are serialized and compressed into a chunk * @return a compressed chunk as string// w ww . j a v a 2 s . com */ public static String fromProtocolBuffersToChunk(ProtocolBuffer.Points data) { byte[] compressedChunk = Compression.compress(data.toByteArray()); return Base64.encodeBase64String(compressedChunk); }
From source file:com.vmware.o11n.plugin.crypto.service.CryptoDigestService.java
public String md5Base64(String dataB64) { validateB64(dataB64); return Base64.encodeBase64String(DigestUtils.md5(Base64.decodeBase64(dataB64))); }
From source file:com.likya.tlos.utils.PasswordService.java
public static synchronized String encrypt(String plaintext) throws Exception { MessageDigest md = null;//from w w w .j a v a2 s. c om try { md = MessageDigest.getInstance("SHA"); // step 2 //$NON-NLS-1$ } catch (NoSuchAlgorithmException e) { throw new Exception(e.getMessage()); } try { md.update(plaintext.getBytes("UTF-8")); // step 3 //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { throw new Exception(e.getMessage()); } byte raw[] = md.digest(); // step 4 /** * Sun uygulamasndan vazgeilip apache uygulamas kullanld * 16.03.2011 * */ // String hash = (new BASE64Encoder()).encode(raw); // step 5 String hash = Base64.encodeBase64String(raw); return hash; // step 6 }
From source file:com.sds.acube.ndisc.mts.xserver.util.XNDiscCipher.java
/** * //from ww w . j a v a 2 s .c o m * * @param data ? ? * @return ? ? */ public static String encode(String data) { try { Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key); byte e[] = cipher.doFinal(data.getBytes("UTF-8")); return replaceChar(Base64.encodeBase64String(e)); } catch (NoSuchAlgorithmException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } catch (NoSuchPaddingException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } catch (InvalidKeyException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } catch (IllegalBlockSizeException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } catch (BadPaddingException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } catch (UnsupportedEncodingException e) { System.err.print(XNDiscUtils.printStackTrace(e)); } return null; }
From source file:io.jsonwebtoken.impl.Base64Codec.java
public String encode(byte[] data) { //return javax.xml.bind.DatatypeConverter.printBase64Binary(data); return Base64.encodeBase64String(data); }
From source file:com.lingxiang2014.util.RSAUtils.java
public static String encrypt(PublicKey publicKey, String text) { Assert.notNull(publicKey);/*from w w w . j av a 2 s .c om*/ Assert.notNull(text); byte[] data = encrypt(publicKey, text.getBytes()); return data != null ? Base64.encodeBase64String(data) : null; }
From source file:com.moz.fiji.hive.utils.FijiDataRequestSerializer.java
/** * Serializes a data request./*from w ww .j a v a 2 s . c om*/ * * @param dataRequest A data request. * @return The serialized data request. * @throws IOException If there is an error. */ public static String serialize(FijiDataRequest dataRequest) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); try { oos.writeObject(dataRequest); oos.flush(); return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(oos); } }
From source file:com.bconomy.autobit.Encryption.java
public static String encrypt(String cleartext) { if (cleartext == null || cleartext.equals("")) return ""; try {/*www. j av a 2 s . com*/ return Base64.encodeBase64String(encrypt(cleartext.getBytes("UTF-8"))); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return ""; }
From source file:de.brands4friends.daleq.core.Base64TemplateValue.java
@Override public Object transform(final long value) { return Base64.encodeBase64String(Longs.toByteArray(value)); }