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.
<?php
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
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #React
- #Class
- #centOS
- #Json
- #Text
- #API
- #URL
- #Encrypting
- #Redirect
- #Form
- #Special Characters
- #Special
- #Random
- #Generating
- #SASS
- #Version
- #Installation
- #Show
- #
- #Ajax
- #method
- #Logic For Displaying Posts
- #Key
- #DDOS
- #Default Value
- #Comment Line
- #1364 Field
- #Error
- #Abbreviation
- #QR Code Generating
- #Date
- #timeAgo
- #cURL
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Vite
- #Reading Excel Files
- #Activate
- #Reading
- #Composer
- #Autoloader
- #PSR-4
- #Insert
- #Record
- #Real Time
- #Characters
- #Socket.io
There are no comments, make the firs comment