how to purposefully mismatch database entries?
0
votes
1
answer
50
views
I've got my standard MariaDB database with phpMyAdmin.
I'm working with OpenSSL and php. And I've got nothing more than a basic rented web-server.
$cipher_algo = 'aes-128-cbc';
$key = '2IZVjWzP5jebqU2LtGdQsyM937OIOdvY';
$iv_length = openssl_cipher_iv_length($cipher_algo);
$iv = openssl_random_pseudo_bytes($iv_length);
$options = 0; //base 64 encoded string
$toCipher = "text to crack";
$encrypted = openssl_encrypt($toCipher, $cipher_algo, $key, $iv_length, $iv);
$deCrypted = openssl_decrypt($encrypted, $cipher_algo, $key, $iv_length, $iv);
1) - I've got my text that I encrypt: the encrypted text.
2) - I've got the Initialisation Vector (IV) that I also store in a DB.
3) - The Key to (de)crypt the text with the IV.
The Key: I can store that in an .environment file above the server root.
I don't want to put the encrypted text and the IV next to each other in the same table, for obvious reasons.
So I'm thinking with the means that I have: a different Database, in unfortunately the same server.
BUT:
I can use an elaborate unique value to link the IV to the encrypted text. And I could encrypt these unique values so that they don't appear the same when you place the tables next to each other.
But if the database is hacked and somebody is looking through it. Than who cares how magical and unique these values are. Entry 1 in the first database probably links up to entry 1 on the second database. And entry 2 in DB1 with entry 2 in DB2. and so on.
So what is a propper way to mismatch entry fields in different tables/databases?
OR, what are my other options?
Asked by Desert Wind
(43 rep)
Jun 1, 2025, 05:22 PM
Last activity: Jun 1, 2025, 07:28 PM
Last activity: Jun 1, 2025, 07:28 PM