public static String decryptOpenSSL(String key,String data) throws IOException, GeneralSecurityException{ OpenSSL opensll=new OpenSSL(); InputStream is=OpenSSL.decrypt("AES256", key.getBytes(), new ByteArrayInputStream(data.getBytes())); Base64 encode=new Base64(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response); //return encode.encode(response.toString().getBytes()).toString(); return response.toString(); } public static String encryptOpenSSL(String key,String data) throws IOException, GeneralSecurityException{ OpenSSL opensll=new OpenSSL(); InputStream is=OpenSSL.encrypt("AES256", key.getBytes(), new ByteArrayInputStream(data.getBytes()), true); BufferedReader in = new BufferedReader(new InputStreamReader(is)); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response); return response.toString(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)