Laravel Encryption


Laravel Encryption – Laravel provides strong facilities for encryption. It provides the AES encryption via the Mcrypt PHP extension. Here in this tutorial we are going to explain the encryption with example.


Laravel Encryption : Encrypt Decrypt Example

Encrypt A Value

You can encrypt a value in laravel as below –

Laravel Encryption Example: Encrypt Value

$encryptedValue = Crypt::encrypt($value);

It will give you the encrypted value.

Note : Set a character 16, 24 or 32 random string in the config/app.php.

Decrypt A Value

You can decrypt a value in laravel as below –

Laravel Encryption Example: Decrypt Value

$decryptedValue = Crypt::decrypt($encryptedValue);

It will give you the decrypted value.


Advertisements

Add Comment

📖 Read More