I have to call an external REST service and I have to decode the response.
From external service documentation I think I have to decode the response with AES algorithm in this way:
public static string decrypt(string encryptedText, string secretKey)
{
blob encryptedData = EncodingUtil.base64Decode(encryptedText);
blob iv = first 16 byte of encryptedData
blob message = then 17 byte of encryptedData
blob decryptedData= Crypto.decrypt('AES256', secretKey, iv, message);
return decryptedData.toString();
}
But I can't figure out how take the bytes from Blob object