Secure the data of your websites by encrypting them. They will be decrypted only in your applications with your secret key
- Firstly you need composer
- Run the command
composer require claudye/php-crypter
- Clone or download from github
- Be sure you have composer installed
- Goto the root of your project and open there a shell (terminal)
- Run
composer install
When php crypter is successful installed, please import the Encryption class like :
use PHPCrypter\Encryption\Encryption;
- To encrypt a data, you use
Encryption::encrypt(string $text, string $algo_method="AES-128-CBC", string $token=null)
This method requires the data to be encrypted, other arguments are optional. It returns encrypted data that you can store or write somewhere for reuse - To decrypt the encrypted information later you can use the method
Encryption::decrypt(string $data_encrypted)
This method will use the generated key for you to decrypt the data which was encrypted. This key must be secret
use PHPCrypter\Encryption\Encryption;
//You can define your key any where you want
//define("ENC_TOKEN_PATH", "your/dir/example");
require 'vendor/autoload.php';
// Encrypt the text "The only limit of a developer is his imagination"
$encrypt = Encryption::encrypt("The only limit of a developer is his imagination");
//You store the encrypted data in a file or in a database, or any where you can reuse it
//After you want to use it again on your site
//Get your text: $encrypt and then decrypt it
$decrypt = Encryption::decrypt($encrypt);
//All right !
It is possible to change the encryption key path (file or directory) where you want to store the secret key! It's a good idea to choose a very secure path
All you have to do is define a constant called: ENC_TOKEN_PATH
, in your project where our script can find it
The encryption method used by default is : AES-128-CBC Find all the methods here
When your data is encrypted with a key, only this key can decrypt it, so be careful not to lose your keys or change your keys carelessly.