protected String decryptString(byte[] encryptedString, byte[] iv, byte[] key) throws IOException, UnsupportedEncodingException { InputStream encryptedStream = cryptoHelper.decrypt(new ByteArrayInputStream(encryptedString), iv, key); byte[] b = IOUtils.toByteArray(encryptedStream); return new String(b, "utf-8"); }
protected DecryptedData getContentFromFileSystem(byte[] id, byte[] iv, byte[] key) { String[] s = getPathAndNameFromDatabase(id, iv, key); if (s != null) { try { FileInputStream fis = new FileInputStream(s[0]); DecryptedData dd = new DecryptedData(); InputStream is = cryptoHelper.decrypt(fis, iv, key); String fileName = s[1]; dd.setContent(is); dd.setFilaName(fileName); return dd; } catch (IOException e) { throw new RuntimeException(e); } } else { return null; } }