I would like to encrypt the Serial Monitor messages so that with only one key it is possible to decrypt the messages printed by Serial Monitor.
Some approach, using the ‘platformio.ini’ settings:
monitor_filters = ‘decryption key’
I know it’s possible to encrypt the ESP32 flash, but I’m using the ESP8266 NodeMCU (which has USB). And I would like to encrypt only the Serial Monitor messages.
Flash encryption only protects the firmware image from being read out externally (without knowing the key). You can encrypt your flash image and still have the firmware print out sensitive plaintext data over serial, those two things are completely separate from each other.
If you additionally want to protect the content of the messages sent via UART to be encrypted, you have to do add that into your software, see e.g. https://www.embedded.com/how-to-secure-uart-communications-in-iot-devices/ for some ideas.