public function testEncryptDecryptAES256() { for ($i = 0; $i < 5; $i++) { $txt = _Rand::_randString(_Rand::_getRand(1, 3000)); $key = _Rand::_randString(_Rand::_getRand(1, 3000)); $encrypted = _Crypt::_encryptAESPKCS7($txt, $key, MCRYPT_RIJNDAEL_256); $decrypted = _Crypt::_decryptAESPKCS7($encrypted, $key, MCRYPT_RIJNDAEL_256); $this->assertEquals($txt, $decrypted); } }
<?php include 'vendor/autoload.php'; use _\_Crypt; $keys = _Crypt::_generateRSAKeys(); $textToEncryptRSA = 'I\'m encrypted with RSA'; $encryptedTextRSA = _Crypt::_encryptRSA($textToEncryptRSA, $keys['public']); $decryptedTextRSA = _Crypt::_decryptRSA($encryptedTextRSA, $keys['private']); $key = "someSecretKey"; $textToEncryptAES = 'I\'m encrypted with AES'; $encryptedTextAES = _Crypt::_encryptAESPKCS7($textToEncryptAES, $key); $decryptedTextAES = _Crypt::_decryptAESPKCS7($encryptedTextAES, $key); ?> <html> <body> <p>RSA Keys:</p> <p><pre><?php var_dump($keys); ?> </pre></p> <p>RSA:</p> <p><pre>Encrypted: <?php echo $encryptedTextRSA; ?> </pre></p> <p><pre>Decrypted: <?php echo $decryptedTextRSA; ?> </pre></p>