WEB DEVELOPER SITE
TUTORIALS HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Laravel - Encryption


Encryption is a procedure of changing over a plain content to a message utilizing a few calculations and third client party can't peruse the data .it is useful for transmitting touchy data . The content which is to be encoded is named as Plain Text and the content or the message acquired after the encryption is called Cipher Text. The way toward changing over figure content to plain content is called Decryption.Laravel utilizes AES-256 and AES-128 encrypter, which utilizes Open SSL for encryption. Every one of the qualities incorporated into Laravel are marked utilizing the convention Message Authentication Code

Configuration

The direction used to produce the key in Laravel is appeared beneath −

php craftsman key:generate 

The qualities for encryption are legitimately adjusted in the config/app.php record, which incorporates two parameters for encryption to be specific key and figure. On the off chance that the esteem utilizing this key isn't appropriately adjusted, every one of the qualities encoded in Laravel will be uncertain.

Encryption Process

Encryption of an esteem should be possible by utilizing the scramble assistant in the controllers of Laravel class. All the scrambled qualities are marked with Message Authentication code (MAC) to check for any adjustments of the encoded string.
<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

use App\Http\Controllers\Controller; 

class DemoController extends Controller{ 

** 

* Store a mystery message for the user. 

* 

* @param Request $request 

* @param int $id 

* @return Response 

*/ 

public function storeSecret(Request $request, $id){ 

$user = User::findOrFail($id); 

$user->fill([ 

'secret' => encrypt($request->secret) 

])- >save(); 

} 

}

Decryption Process

Decryption of the qualities is finished with the decrypt helper. Wat