To prevent sensitive images shared on social media from being stolen, researchers are seeking to find and innovate image encryption algorithms. Since attackers attempt to exploit it to access encrypted images, the problem of generating keys as the first stage of any encryption algorithm is regarded as a critical problem. This issue was dealt with in this paper through the use of the logistic map. This map must be calculated using specific conditions and special parameters to maintain its chaos. The Diffie-Hellman key exchange algorithm was modified to address this problem since the shared keys now consist of a 16-element vector. The first two elements will be used for a logistic map. The entire vector was used to create a self-invertible matrix. The encryption level entails two operations: the first is matrix multiplication with a vector, and the second is a bitwise XOR
operation between two matrices. A proposed encryption algorithm is capable of producing encrypted images that are challenging to decrypt through the use of stringent security tests. The outcomes of each test show how well the proposed encryption algorithm performs compared with other algorithms and how to resist the attacks.