April 14, 2018 —John Koster
The encrypt
helper function can be used to encrypt a given string value. The function resolves the configured "Illuminate\Contracts\Encryption\Encrypter" implementation from the Service Container and then calls the encrypt
method on the Encrypter
instance.
The signature of the encrypt
function is:
1function encrypt(2 $value3);
The following examples are all equivalent:
1use Illuminate\Support\Facades\Crypt; 2 3// Encrypt using the Crypt facade: 4Crypt::encrypt('Hello, Universe'); 5 6// Encrypt using the encrypt helper: 7encrypt('Hello, Universe'); 8 9// Retrieve an instance from the Service Container.10app('encrypter')->encrypt('Hello, Universe');11 12// Retrieve an instance from the Service Container.13resolve('encrypter')->encrypt('Hello, Universe');
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.