# AES-256-CBC with random IV - storing same plaintext as same ciphertext

I am encrypting some information stored in a column of a MySQL database. The column can contain repeated values, let's say the table has 7 rows and the column to be encrypted has the following values:

"a", "b", "a", "c", "b", "b", "c"

I would like to know if is insecure to encrypt just one time each different value (each one with a random IV stored along with the ciphertext) and to reuse the same ciphertext for the same plaintext.

Let's say that the encryption of "a" with a random IV (IV1) gives "z", the encryption of "b" with another random IV (IV2) gives "x" and the encryption of "c" with another random IV (IV3) gives "k". Would it be insecure to have all the "a"s encrypted as "z", all the "b"s encrypted as "x" and all the "c"s encrypted as "k"?

"z", "x", "z", "k", "x", "x", "k"

I often read that it is a weakness to have the same ciphertext for the same plaintext, but I was wondering if this weakness is no longer present if you use a random IV each time to encrypt the data.

• To encrypt all $a$ as $z$ would be a simple substituition cipher, and not very secure, because it's very vulnerable to cryptanalysis. – AleksanderRas Jan 18 '19 at 8:28
• Do you want to execute equality queries over the encrypted data? – kelalaka Jan 18 '19 at 9:41
• @kelalaka not only, also LIKE queries. Why? – user65131 Jan 18 '19 at 13:18
• Because you designed the CBC in a way that it supports equality. Do you know the frequency of the data beforehand? – kelalaka Jan 18 '19 at 14:00