/** * Encodes binary data using the base64 algorithm and chunks * the encoded output into 76 character blocks * * @param binaryData binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(final byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes binary data using the base64 algorithm but * does not chunk the output. * * @param binaryData binary data to encode * @return Base64 characters */ public static byte[] encodeBase64(byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes binary data using the base64 algorithm but * does not chunk the output. * * @param binaryData binary data to encode * @return Base64 characters */ public static byte[] encodeBase64(final byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes binary data using the base64 algorithm and chunks * the encoded output into 76 character blocks * * @param binaryData binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(final byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes binary data using the base64 algorithm but * does not chunk the output. * * @param binaryData binary data to encode * @return Base64 characters */ public static byte[] encodeBase64(final byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes a byte[] containing binary data, into a byte[] containing * characters in the Base64 alphabet. * * @param pArray a byte array containing binary data * @return A byte array containing only Base64 character data */ public byte[] encode(final byte[] pArray) { return encodeBase64(pArray, false); }
/** * Encodes a byte[] containing binary data, into a byte[] containing * characters in the Base64 alphabet. * * @param pArray a byte array containing binary data * @return A byte array containing only Base64 character data */ public byte[] encode(final byte[] pArray) { return encodeBase64(pArray, false); }
/** * Encodes binary data using the base64 algorithm and chunks * the encoded output into 76 character blocks * * @param binaryData binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes a byte[] containing binary data, into a byte[] containing * characters in the Base64 alphabet. * * @param pArray a byte array containing binary data * @return A byte array containing only Base64 character data */ public byte[] encode(byte[] pArray) { return encodeBase64(pArray, false); }
private String serializeObject(Object object) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(object); out.close(); byte[] encoded = Base64.encodeBase64(baos.toByteArray()); return new String(encoded); } catch (IOException e) { throw new RuntimeException(e); } }
/** * @see PasswordCipher#encrypt(java.lang.String) * @throws RuntimeException * in any case of error. */ public char[] encrypt(String plainPassword) { if ((null == plainPassword) || plainPassword.length() == 0) { throw new IllegalArgumentException("plainPassword cannot be null nor empty."); } byte[] plaintext = plainPassword.getBytes(); try { // Get a 3DES Cipher object Cipher cipher = Cipher.getInstance(TRANSFORMATION); // Set it into encryption mode cipher.init(Cipher.ENCRYPT_MODE, KEY); // Encrypt data byte[] cipherText = cipher.doFinal(plaintext); return new String(Base64.encodeBase64(cipherText)).toCharArray(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @throws RuntimeException in any case of error. * @see org.apache.openejb.cipher.PasswordCipher#encrypt(String) */ public char[] encrypt(final String plainPassword) { if (null == plainPassword || plainPassword.length() == 0) { throw new IllegalArgumentException("plainPassword cannot be null nor empty."); } final byte[] plaintext = plainPassword.getBytes(); try { // Get a 3DES Cipher object final Cipher cipher = Cipher.getInstance(TRANSFORMATION); // Set it into encryption mode cipher.init(Cipher.ENCRYPT_MODE, KEY); // Encrypt data final byte[] cipherText = cipher.doFinal(plaintext); return new String(Base64.encodeBase64(cipherText)).toCharArray(); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }
/** * @throws RuntimeException in any case of error. * @see org.apache.openejb.cipher.PasswordCipher#encrypt(String) */ public char[] encrypt(final String plainPassword) { if (null == plainPassword || plainPassword.length() == 0) { throw new IllegalArgumentException("plainPassword cannot be null nor empty."); } final byte[] plaintext = plainPassword.getBytes(); try { // Get a 3DES Cipher object final Cipher cipher = Cipher.getInstance(TRANSFORMATION); // Set it into encryption mode cipher.init(Cipher.ENCRYPT_MODE, KEY); // Encrypt data final byte[] cipherText = cipher.doFinal(plaintext); return new String(Base64.encodeBase64(cipherText)).toCharArray(); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }
return real.equalsIgnoreCase(HexConverter.bytesToHex(data)); } else if ("base64".equalsIgnoreCase(encoding)) { return real.equals(new String(Base64.encodeBase64(data)));
return real.equalsIgnoreCase(HexConverter.bytesToHex(data)); } else if ("base64".equalsIgnoreCase(encoding)) { return real.equals(new String(Base64.encodeBase64(data)));
return real.equalsIgnoreCase(HexConverter.bytesToHex(data)); } else if ("base64".equalsIgnoreCase(encoding)) { return real.equals(new String(Base64.encodeBase64(data)));
String encoded = new String(Base64.encodeBase64((username + ":" + password).getBytes())); huc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
final String encoded = new String(Base64.encodeBase64((username + ":" + password).getBytes())); huc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
final String encoded = new String(Base64.encodeBase64((username + ":" + password).getBytes())); huc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);