How To Encrypt And Decrypt String In Laravel 8

Websolutionstuff | May-07-2021 | Categories : Laravel

In this example we will see how to encrypt and decrypt string in laravel 8 using crypt helper, As we all know laravel framework provide more security to user and that's why laravel provide encrypt of password or string to user, here we will see how to encrypt or decrypt string in laravel.

You need to use Crypt class to start encryptString and decryptString or some data.

 

use Crypt;
use App\Model\User;

 

Example 1 :

 

$user = new User();
$user->password = Crypt::encrypt($data['password']);
$user->save();

  public function encrypt()
   {
        $encrypted = Crypt::encryptString('websolutionstuff');
        print_r($encrypted);
   }
   
    public function decrypt()
    {
         $decrypt= Crypt::decryptString('your_encrypted_string');
         print_r($decrypt);
    }

 

Example 2 : 

 

$data = Request::all();

$user = new User();
$user->password = Crypt::encrypt($data['password']);
$user->save();

foreach ($user as $row)
{
  Crypt::decrypt($row->password);
}

 

Recommended Post
Featured Post
How To Send Email In Laravel 9 Using Mailgun
How To Send Email In Laravel 9...

In this article, how to send email in laravel 9 using mailgun. we will learn laravel 9 to send emails using mailgun...

Read More

Jul-29-2022

How To Install Angular In Ubuntu
How To Install Angular In Ubun...

In this article, we will see how to install angular in ubuntu. Angular is a framework, library, assets, a...

Read More

May-09-2022

Laravel 11 Use Quill Rich Text Editor Example
Laravel 11 Use Quill Rich Text...

Hello, laravel web developers! In this article, we'll see how to use Quill rich text editor in laravel 11. Here, we&...

Read More

Sep-04-2024

Introduction of Node.js Modules
Introduction of Node.js Module...

In this tutorial I will give you information about Introduction of Node.js Modules. Node.js modules provide a way t...

Read More

Sep-10-2021