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 Store Backup On Dropbox In Laravel 9
How To Store Backup On Dropbox...

In this article, we will see how to store the backup on dropbox in laravel 9. Here, we will learn to store database...

Read More

Jan-16-2023

How To Validate International Phone Number Using jQuery
How To Validate International...

In this article, we will see how to validate international phone numbers using jquery. Here, we will learn about mo...

Read More

May-12-2023

How to Upload File on the FTP Server Using PHP
How to Upload File on the FTP...

In this small post i will show you how to upload file on the ftp server using php. As we know there are many ftp functio...

Read More

May-20-2021

Laravel 9 Vue JS Search Example
Laravel 9 Vue JS Search Exampl...

In this article, we will see a laravel 9 vue js search example. Here, we will learn how to live search in laravel 9 usin...

Read More

Dec-14-2022