I am trying to hash my data before saving it to the database mainly to:
1) Save the size of the data being saved - If you are going to save large lines of data
2) Security.
I believe what you are looking for is encryption. A standard Hash is one way you cannot get the data back out. Using encryption you can go back and forth.
I am trying to hash my data before saving it to the database mainly to: 1) Save the size of the data being saved - If you are going to save large lines of data 2) Security.
Only point two (2) really makes sense. As @tray2 said, encrypting is not a space saving mechanism, it is for security purposes only. If you are trying to be storage-conscious, which is always a good idea, maybe you can only encrypt the sensitive data, as opposed to encrypting the whole DB. To do so, consider using an Encyptable Trait. It's not too difficult to set up on your own but if you prefer a package, here is one that looks pretty straightforward:
@gouseferoz Encryption does not equate with compression. To encrypt in and out of the database, the methods I suggested above are the right way to go about it. Those encryption methods are salted by your APP_KEY in your env file, it isn't one way... fairly secure for what you are trying to do.
Compressing in and out of a database... you would literally lose speed doing the compression and decompression waaaaay more than having it compressed would save you in the first place. There is a reason that isn't common practice.