+ README.md\n+ example.php\n + license
This commit is contained in:
parent
3d08bcd3c7
commit
d269906413
|
@ -0,0 +1 @@
|
|||
config.inc.php
|
|
@ -0,0 +1,29 @@
|
|||
## About
|
||||
|
||||
The Project is a simple php encryption wrapper, not even a library, the whole point is that it has integrity checks on the encryption part which helps out quite a bit with errors.
|
||||
|
||||
|
||||
## Usage
|
||||
Simply use the provided functions from the lib.php file, you can simply import it into any project using that file.
|
||||
|
||||
```php
|
||||
require_once("/path/to/the/file/kpcrypt/lib.php)
|
||||
|
||||
$input = "Super secret string!";
|
||||
$key = "My key to encrypt the string with";
|
||||
|
||||
// Encrypt the data, the cipher can be easily changed, the integrity_check is recommended to be left to TRUE even if it takes some extra time to decrypt and check.
|
||||
$encryptedData = encryptData($input, $key, 'AES-256-CBC', TRUE);
|
||||
|
||||
// Echo out the encrypted values to check them
|
||||
|
||||
echo "Encrypted: " . $encryptedData;
|
||||
echo "\n";
|
||||
echo "Decrypted: " . decryptData($encryptedData, $key);
|
||||
echo "\n";
|
||||
echo "Peak Memory: " . memory_get_peak_usage() / 1024 . "Kb"; // Check the memory in kb
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
The licensing of the project is the [MIT license](https://mit-license.org/)
|
|
@ -1,3 +1,4 @@
|
|||
<?php
|
||||
|
||||
$config[''] = "";
|
||||
$config['key'] = "国建尸造就拍摄体效能倍";
|
||||
$config['input'] = "Some kind of string we'd like to keep safe!";
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
require_once("./lib.php");
|
||||
|
||||
// TODO: An example for command line interface usage
|
12
example.php
12
example.php
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
require_once("./lib.php");
|
||||
@require_once("./config.inc.php");
|
||||
|
||||
// Check if the config succesfully loaded, or if the mandatory config fields are missing.
|
||||
if ( empty($config) || empty($config['key']) || empty($config['input']) ) {
|
||||
echo "Please copy the config.sample.inc.php to config.inc.php and change the configuration to match your needs.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Echo out the results
|
||||
echo $encryptedData = encryptData($config['input'], $config['key'], 'AES-256-CBC', TRUE);
|
16
lib.php
16
lib.php
|
@ -1,12 +1,4 @@
|
|||
<?php
|
||||
|
||||
// The key to use in the encryption
|
||||
$key = "my Key";
|
||||
|
||||
// The string to encrypt, this can be any string.
|
||||
$string = "Super secret password we should store away safely";
|
||||
|
||||
|
||||
/**
|
||||
* @param string $data The data to be encrypted, this can only encrypt strings.
|
||||
* @param string $key The key to use to encrypt the data, this key should be generated using the openssl_random_pseudo_bytes
|
||||
|
@ -86,11 +78,3 @@ function decryptData( string $data, string $key, string $cipherMethod = 'AES-256
|
|||
// Return the data
|
||||
return $data;
|
||||
}
|
||||
|
||||
$encryptedData = encryptData($string, $key);
|
||||
|
||||
echo "Encrypted: " . $encryptedData;
|
||||
echo "\n";
|
||||
echo "Decrypted: " . decryptData($encryptedData, $key);
|
||||
echo "\n";
|
||||
echo "Peak Memory: " . memory_get_peak_usage() / 1024 . "Kb";
|
|
@ -0,0 +1,9 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright 2021 Kato Twofold
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Reference in New Issue