phpseclib/tests/Unit/Crypt/RSA/ModeTest.php

31 lines
727 B
PHP
Raw Normal View History

2015-05-26 03:30:38 +00:00
<?php
/**
* @author Jim Wigginton <terrafrost@php.net>
* @copyright 2013 Jim Wigginton
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
use phpseclib\Crypt\RSA;
2015-05-26 03:30:38 +00:00
class Unit_Crypt_RSA_ModeTest extends PhpseclibTestCase
{
public function testEncryptionModeNone()
{
$plaintext = 'a';
$rsa = new RSA();
2015-05-26 03:30:38 +00:00
extract($rsa->createKey());
$rsa->loadKey($publickey);
$rsa->setEncryptionMode(RSA::ENCRYPTION_NONE);
2015-05-26 03:30:38 +00:00
$a = $rsa->encrypt($plaintext);
$b = $rsa->encrypt($plaintext);
$this->assertEquals($a, $b);
$rsa->loadKey($privatekey);
$this->assertEquals(trim($rsa->decrypt($a), "\0"), $plaintext);
}
}