Setting the Encryption Key

Problem

You want to set your own encryption key.

Solution

Use Crypt::setKey().

Crypt::setKey($key);

Discussion

This key will be used for subsequent Crypt::encrypt() and Crypt::decrypt() calls.

But only in the current request.

By default Laravel automatically uses Config::get('app.key') as the key for encryption. If you change the key, any subsequent calls to Crypt::decrypt() will only only work for values that have been encrypted with the same key.

comments powered by Disqus