diff --git a/tests/third_party/php-encryption/create_random_key.php b/tests/third_party/php-encryption/create_random_key.php new file mode 100644 index 0000000..dd1fab3 --- /dev/null +++ b/tests/third_party/php-encryption/create_random_key.php @@ -0,0 +1,9 @@ +saveToAsciiSafeString(); + + print('Key: ' . $ascii_key . PHP_EOL); \ No newline at end of file diff --git a/tests/third_party/php-encryption/encryption_decryption.php b/tests/third_party/php-encryption/encryption_decryption.php new file mode 100644 index 0000000..efcb77a --- /dev/null +++ b/tests/third_party/php-encryption/encryption_decryption.php @@ -0,0 +1,28 @@ +saveToAsciiSafeString(); + + print('Key: ' . $ascii_key . PHP_EOL); + + + print('Encrypting message \'Hello NCC!\' as raw binary' . PHP_EOL); + $encrypted_message = \ncc\Defuse\Crypto\Crypto::encrypt('Hello NCC!', $key, true); + print('Encrypted Message: ' . $encrypted_message . PHP_EOL); + + + print('Decrypting message' . PHP_EOL); + $decrypted_message = \ncc\Defuse\Crypto\Crypto::decrypt($encrypted_message, $key, true); + print('Decrypted Message: ' . $decrypted_message . PHP_EOL); + + if(hash('md5', 'Hello NCC!') == hash('md5', $decrypted_message)) + { + print('Encryption/Decryption test successful' . PHP_EOL); + } + else + { + print('Encryption/Decryption test fail' . PHP_EOL); + }