I've dowloaded 'defuse/php-encryption' from GitHub.
I tried the exemple founded here : How do you Encrypt and Decrypt a PHP String? but I didn't succeed.
"test.php" is in the same folder with "Crypto.php" :
<?php
// This requires https://github.com/defuse/php-encryption
// php composer.phar require defuse/php-encryption
// Note: Crypto::Encrypt() returns raw binary, so you may want to use base64_encode() and base64_decode()for storing/transmitting ciphertexts to prevent encoding bugs.
ini_set('display_errors', 1); error_reporting(E_ALL);
require ("Crypto.php");
// Do this once then store it somehow:
$key = Crypto::CreateNewRandomKey();
$message = 'We are all living in a yellow submarine';
$ciphertext = Crypto::Encrypt($message, $key);
$plaintext = Crypto::Decrypt($ciphertext, $key);
if ($ciphertext === $plaintext)
{echo "<br><font color=green>Operation cryp - décrypt OK !!!!</font><br><br><br>$ciphertext === $plaintext<br><br>";}
else
{echo "<br><font color=red>Operation cryp - décrypt NOK !!!!</font><br><br>$ciphertext === $plaintext<br><br>";}
?>
The result is :
Fatal error: Class 'Crypto' not found in /home/zideesdubj/www/_tests2enfants/_test_session/php-encryption-master/php-encryption-master/src/test.php on line 10
With your help, I replaced "require ("Crypto.php");" by "require('php-encryption-master/autoload.php'); But it's the same result :
Fatal error: Class 'Crypto' not found in /home/zideesdubj/www/_tests2enfants/_test_session/php-encryption-master/test.php on line 10
Have you got any basic example to use 'defuse/php-encryption' ?
I understand this is a question from a dummy but I don't find any answer or tutorial on the web.
Thanks !