You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
1.1 KiB

  1. <?php
  2. /**
  3. * PhpUnderControl_PhalApiCryptRSAPri2Pub_Test
  4. *
  5. * 针对 ../../../PhalApi/Crypt/RSA/Pri2Pub.php PhalApi_Crypt_RSA_Pri2Pub 类的PHPUnit单元测试
  6. *
  7. * @author: dogstar 20150315
  8. */
  9. require_once dirname(__FILE__) . '/../../test_env.php';
  10. if (!class_exists('PhalApi_Crypt_RSA_Pri2Pub')) {
  11. require dirname(__FILE__) . '/../../../PhalApi/Crypt/RSA/Pri2Pub.php';
  12. }
  13. class PhpUnderControl_PhalApiCryptRSAPri2Pub_Test extends PHPUnit_Framework_TestCase
  14. {
  15. public $phalApiCryptRSAPri2Pub;
  16. protected function setUp()
  17. {
  18. parent::setUp();
  19. $this->phalApiCryptRSAPri2Pub = new PhalApi_Crypt_RSA_Pri2Pub();
  20. }
  21. protected function tearDown()
  22. {
  23. }
  24. public function testHere()
  25. {
  26. $keyG = new PhalApi_Crypt_RSA_KeyGenerator();
  27. $prikey = $keyG->getPriKey();
  28. $pubkey = $keyG->getPubkey();
  29. $data = 'something important here ...';
  30. $encryptData = $this->phalApiCryptRSAPri2Pub->encrypt($data, $prikey);
  31. $decryptData = $this->phalApiCryptRSAPri2Pub->decrypt($encryptData, $pubkey);
  32. $this->assertEquals($data, $decryptData);
  33. }
  34. }