Я пытался расшифровать зашифрованную полезную нагрузку, полученную в ответ на вызов API, используя SEK
Вот код java
public static Response decryptPayload(String inputJson, String decrptySek) throws Exception{
//tried with both passing only data And Json
JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(inputJson);
String data_todecrypt=json.get("Data").toString();
byte[] sekByte = Base64.decodeBase64(decrptySek.getBytes());
byte[] decoded = Base64.decodeBase64(data_todecrypt.getBytes());
Key aesKey = new SecretKeySpec(sekByte, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, aesKey);
byte[] encryptedjsonbytes = cipher.doFinal(decoded);
byte[] encryptedJson1 = Base64.decodeBase64(encryptedjsonbytes);
//byte[] encryptedJson1 = Base64.encodeBase64(encryptedjsonbytes);
String encryptedJson = new String(encryptedJson1);
return encryptedJson;
}
Я получаю нежелательные значения как вывод, когда я расшифровываю, где я ожидаю JSON
Может кто-нибудь помочь