byte[] toEncode = new byte[salt.length + dataBytes.length]; System.arraycopy(salt, 0, toEncode, 0, salt.length); System.arraycopy(dataBytes, 0, toEncode, salt.length, dataBytes.length);
byte[] toEncode = new byte[VERSION.length + salt.length + dataBytes.length]; System.arraycopy(VERSION, 0, toEncode, 0, VERSION.length); System.arraycopy(salt, 0, toEncode, VERSION.length, salt.length); System.arraycopy(dataBytes, 0, toEncode, VERSION.length+salt.length, dataBytes.length);
    public static String encryptData(String dataSourceId, String data) throws ServiceException {        try {            byte[] salt = randomSalt();            Cipher cipher = getCipher(dataSourceId, salt, true);            byte[] dataBytes = cipher.doFinal(data.getBytes("utf-8"));            byte[] toEncode = new byte[salt.length + dataBytes.length];            System.arraycopy(salt, 0, toEncode, 0, salt.length);            System.arraycopy(dataBytes, 0, toEncode, salt.length, dataBytes.length);             return new String(Base64.encodeBase64(toEncode));        } catch (UnsupportedEncodingException e) {            throw ServiceException.FAILURE("caught unsupport encoding exception", e);        } catch (GeneralSecurityException e) {            throw ServiceException.FAILURE("caught security exception", e);         }    }