コード例 #1
0
 public function testRSAEncryptDecrypt4096()
 {
     $keys = _Crypt::_generateRSAKeys(4096);
     for ($i = 0; $i < 5; $i++) {
         $txt = _Rand::_randString(_Rand::_getRand(1, 3000));
         $key = _Rand::_randString(_Rand::_getRand(1, 3000));
         $encrypted = _Crypt::_encryptRSA($txt, $keys['public']);
         $decrypted = _Crypt::_decryptRSA($encrypted, $keys['private'], 4096);
         $this->assertEquals($txt, $decrypted);
     }
 }
コード例 #2
0
<?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>