#rotate APP_KEY and re-encrypt data stored in the database

2 messages · Page 1 of 1 (latest)

mighty tundra
#

can anyone please help me with best process to follow when rotating app key to make sure all encrypted data works fine after rotation and all the values are re-encrypted?

1 - I see this was planned in the past but seems like the idea was dropped - https://github.com/laravel/framework/pull/37070
2 - I can use this though it requires old key - https://gist.github.com/themsaid/ef376d7642be69c1110a0a49b0beb0ea
issue with this would be that all the data can still be decrypted with old code until all are re-encrypted

any possible solution to change all data at once after rotating keys?

opaque pecan
#

With "all data" you're referring to data that's stored in the database or something? Then yeah, you'd have to create something like a command you'd run once that fetches the data, decrypts it with the old key, encrypts it with the new key and update the values with that