eskimo
eskimo

Reputation: 2624

Is my APP_KEY the only thing unique to Laravel's Crypt

I have a a property stored unencrypted and I'd like to implement that going forward this specific property is encrypted when it's saved. It's also going to be unencrypted when presented in a blade view.

My question is: is the APP_KEY the only thing that's unique that's used for Laravel's Crypt facade?

In other words: if I take the unencrypted values from production, encrypt them locally with the same APP_KEY and then put them back in the prod database, will I be able to then decrypt them successfully on the production server?

Upvotes: 0

Views: 307

Answers (1)

codedge
codedge

Reputation: 5174

As long as you use the same APP_KEY on both (various) systems you should be able to en-/decrypt your data successfully.

if I take the unencrypted values from production, encrypt them locally with the same APP_KEY and then put them back in the prod database, will I be able to then decrypt them successfully on the production server

Yes.

You can see this, when getting the Encrypter service, that it injects the config key / APP_KEY here via calling the parseKey method.

So when calling the encrypt method it already has the application key, $this->key, ready to be applied.

Upvotes: 2

Related Questions