I'm dealing with some small data, which needs padding to help with its security. I need to add random padding to the original string before encrypting it and storing it in a database.
I've read several stack overflow posts asking for a random string, and the resulting answers showed how to create strings that are hex based e.g. They use UUID() or MD5(). I'm looking for higher complexity, so would like to use the RANDOM_BYTES() or something similar (I would settle for a random string that fits a regex like [a-zA-Z0-9]{20}, if the example is clean).
The order of what I'm looking to do is:
Encryption and Persistence:
Original Text ("Hello World") -> Append 20 Random Bytes To String -> AES_Encrypt() -> At this point it would be persisted to the db.
Retrieval:
Query Blob from db -> AES_Decrypt -> Get LEFT 11 characters to return Original Value "Hello World"
My attempt at googling failed as well as my attempts to get it working manually in an sql editor. Any help is appreciated, or if there is a simpler way, I'm game too.
Aucun commentaire:
Enregistrer un commentaire