Laravel Classroom image

Prashant  Nigam / Student / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  First|1 | 2|

21.2 Two Way Encryption
Two way encryption, allows you to return your encrypted data to its original form, kind of like
those spy code sheets you played with when you were a kid!
The Laravel Crypter class uses AES-256 encryption which is provided by the Mcrypt PHP
extension, so make sure that this PHP extension has been installed before attempting to use
the class!
The Crypter class works using two simple methods, encrypt() and decrypt(), let’s take a look
at encrypting a string.
1 <?php
3 $secret = Crypter::encrypt('I actually like Hello Kitty');
Now our dirty little secret has been AES-256 encrypted, and the result has been returned. This
would be of no use if we couldn’t decrypt the secret at a later date. Let’s look at how you can
decrypt an encrypted piece of data.
1 <?php
3 $decrypted_secret = Crypter::decrypt($secret);
Easy as that! Simply hand the encrypted string to the decrypt() and the decrypted result is
handed back.
Enjoy using the Crypter class to simulate the feeling of using your super secret decoder rings
you got that one time in a cereal box!



Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,

  Students (0)