From 628da2f97434a1dae9f0d6b8b188b344de5d369d Mon Sep 17 00:00:00 2001 From: Kato Twofold Date: Sun, 28 Feb 2021 11:25:17 +0200 Subject: [PATCH] --- -String-Encryption.md | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 -String-Encryption.md diff --git a/-String-Encryption.md b/-String-Encryption.md new file mode 100644 index 0000000..31c9849 --- /dev/null +++ b/-String-Encryption.md @@ -0,0 +1,44 @@ +To encrypt a string you may use the `example.php` that was provided in the repository, the bellow example is that file. +```php + $amount) + $str = substr($str, 0, $amount) . '...'; + return $str; +} + +$kpc = new kpcrypt($config['key']); + +echo "Key: " . $kpc->getKey() . " \n"; + +// Echo out the results +$encryptedData = $kpc->encryptData($config['input'], 'AES-256-CBC', TRUE); + +echo "Encrypted: " . limitStringSize($encryptedData); +echo "\n"; +echo "Decrypted: " . limitStringSize($kpc->decryptData($encryptedData)); +echo "\n"; +echo "Peak Memory: " . memory_get_peak_usage() / 1024 / 1024 . "Mb"; // Check the memory in kb +echo "\n\n"; + +// Calculate the string size increse +$inputSize = strlen($config['input']); // Bytes +$outputSize = strlen($encryptedData); // Bytes + +// Echo out sizing information +echo "Sizeof input: " . strlen($config['input']) . "\n"; // Bytes +echo "Sizeof output:" . strlen($encryptedData) . "\n"; // Bytes + +echo "\n"; +``` \ No newline at end of file