PHP 中的 mySQLi SELECT 与另一个 table 的 IV 用于解密 table 列数据

mySQLi SELECT in PHP with another table's IVs for decrypting table column data

我有两个 tables,它们最终将存在于不同的数据库中,但现在我只想集中精力让它在一个数据库上运行。我有一个 table,我们可以称之为 'A',它使用 mcrypt 加密信息,但作为 base64 编码值。每行都有一个单独的 IV 与之关联,存储在另一个 table 上,我们可以称之为 'B'.

如果我想在 php 中做一个 SELECT 语句来得到在 table A 中解密后等于 "Ohio" 的所有美国州,我将如何执行此操作并同时使用 table B 中的每一行将其获取到 select 以提供用于解密的 IV?

澄清一下:

Table答:

编号 |加密值

Table乙:

编号 |四

table A 上的 ID 与 table B 上的 ID 关联。

加入表格并将加密值和相应的IV传递给解密函数。

SELECT a.id, decrypt(a.encrypted_value, b.iv) AS state
FROM tableA as a
JOIN tableB as b ON a.id = b.id
HAVING state = 'Ohio'