| 900 | } |
| 901 | |
| 902 | public static byte[] encryptElementAES(Element element, byte[] secretKey) |
| 903 | throws SecurityException { |
| 904 | byte[] after = null; |
| 905 | try { |
| 906 | ByteArrayOutputStream output = new ByteArrayOutputStream(); |
| 907 | element.writeTo(output); |
| 908 | byte[] before = output.toByteArray(); |
| 909 | after = Crypto.encryptAES(before, secretKey); |
| 910 | } catch (Exception e) { |
| 911 | log.error("Error while encrypting element", e); |
| 912 | throw new SecurityException(e); |
| 913 | } |
| 914 | return after; |
| 915 | } |
| 916 | |
| 917 | public static Element decryptElementAES(byte[] data, byte[] secretKey) |
| 918 | throws SecurityException { |