Published in Laravel

Laravel Helper Function: decrypt

By John Koster

decrypt($value)

The decrypt helper function can be used to decrypt a given $value. The function resolves the configured Illuminate\Contracts\Encryption\Encrypter implementation from the Service Container and then calls the decrypt method on the Encrypter instance.

Assuming a variable $encryptedValue exists and contains a previously encrypted value the following examples are all equivalent:

1<?php
2
3use Illuminate\Support\Facades\Crypt;
4
5$encryptedValue = '...';
6
7// Encrypt using the Crypt facade:
8Crypt::decrypt($encryptedValue);
9
10// Encrypt using the encrypt helper:
11decrypt($encryptedValue);