|
| 1 | +# PHP Crypter |
| 2 | +Secure the data of your websites by encrypting them. They will be decrypted only in your applications with your secret key |
| 3 | + |
| 4 | +# How to install ? |
| 5 | + |
| 6 | + ## With composer |
| 7 | + |
| 8 | + * Firstly you need composer |
| 9 | + * Run the command `composer require claudye/php-crypter` |
| 10 | + |
| 11 | + ## Clone or download from github |
| 12 | + * Clone or download from [github](https://github.com/Claudye/php-crypter) |
| 13 | + * Be sure you have [composer](https://getcomposer.org/) installed |
| 14 | + * Goto the root of your project and open there a shell (terminal) |
| 15 | + * Run `composer install` |
| 16 | + |
| 17 | +# Usage |
| 18 | + When php crypter is successful installed, please import the Encryption class like : |
| 19 | + |
| 20 | + `use PHPCrypter\Encryption\Encryption;` |
| 21 | + |
| 22 | + * To encrypt a data, you use `Encryption::encrypt(string $text, string $algo_method="AES-128-CBC", string $token=null)` |
| 23 | + 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 |
| 24 | + * To decrypt the encrypted information later you can use the method |
| 25 | + `Encryption::decrypt(string $data_encrypted)` |
| 26 | + This method will use the generated key for you to decrypt the data which was encrypted. This key must be secret |
| 27 | + |
| 28 | +# Example |
| 29 | + <pre> |
| 30 | + <code> |
| 31 | + |
| 32 | + use PHPCrypter\Encryption\Encryption; |
| 33 | + //You can define your key any where you want |
| 34 | + |
| 35 | + //define("ENC_TOKEN_PATH", "your/dir/example"); |
| 36 | + |
| 37 | + require 'vendor/autoload.php'; |
| 38 | + // Encrypt the text "The only limit of a developer is his imagination" <br> <br> |
| 39 | + $encrypt = Encryption::encrypt("The only limit of a developer is his imagination"); |
| 40 | + |
| 41 | + //You store the encrypted data in a file or in a database, or any where you can reuse it <br> |
| 42 | + //After you want to use it again on your site <br> |
| 43 | + //Get your text: $encrypt and then decrypt it <br> |
| 44 | + $decrypt = Encryption::decrypt($encrypt); |
| 45 | + |
| 46 | + //All right ! <br> |
| 47 | + |
| 48 | +</code> |
| 49 | +</pre> |
| 50 | + |
| 51 | +# Change encryption key path! |
| 52 | + |
| 53 | + 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 |
| 54 | + |
| 55 | +# Information |
| 56 | +The encryption method used by default is : AES-128-CBC |
| 57 | +[Find all the methods here](https://www.php.net/manual/fr/function.openssl-get-cipher-methods.php) |
| 58 | + |
| 59 | +### Attention! |
| 60 | +**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.** |
0 commit comments