Encrypt a cv::Mat

Hello, How to encrypt a cv::Mat with a home made encryption algorithm ?
Thank you

There is a .data pointer which you can use to access the raw byte data, but pay attention to possible padding. And you will have to remember things like pixel format and image resolution if you later want to use the decrypted data in another cv::Mat

Another way could be to first cv::imencode the data to serial byte array. However encoding to .png will take some processing time. Maybe cv:: imencode to .bmp format is a good way.

Process then would be:
Encrypt:

  1. Mat image input
  2. imencode
  3. encryption on the byte array

Decrypt:

  1. Decryption
  2. imdecode
  3. Mat image output

Take a look at GitHub - imneonizer/imcrypt: Auto Encrypt anything with a private / local key.