Encrypting the values based on a certain key in PHP

There are lot of encrypting algorithm, for example AES (Advanced Encryption Standart). You may use this encryption algorithm in your basic project easily.


function encrypt($string, $key) {
	$encrypted_string = openssl_encrypt($string, "AES-128-ECB", $key);
	return $encrypted_string;

function decrypt($string, $key) {
	$decrypted_string = openssl_decrypt($string, "AES-128-ECB", $key);
	return $decrypted_string;

$key = 'phpExample2021';
$value = 5;
$encryptValue = encrypt($deger, $key); 
echo $encryptValue // Result : vJeZ6vqVNnLG5AELjajNug== bla bla bla..

$originalValue = decrypt($encryptValue , $key);
echo $originalValue; // Result: 5



There are no comments, make the firs comment