From f15bc38520000d384ef282e11744fc64a490cfb0 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 3 Jan 2013 17:48:14 +0100 Subject: [PATCH] [issue/39] Test case for Github ContinuousBuffer issue 39. --- tests/Crypt/AES/ContinuousBufferTest.php | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/Crypt/AES/ContinuousBufferTest.php diff --git a/tests/Crypt/AES/ContinuousBufferTest.php b/tests/Crypt/AES/ContinuousBufferTest.php new file mode 100644 index 00000000..3eef02f2 --- /dev/null +++ b/tests/Crypt/AES/ContinuousBufferTest.php @@ -0,0 +1,26 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Crypt_AES_ContinuousBufferTest extends Crypt_AES_TestCase +{ + // https://github.com/phpseclib/phpseclib/issues/39 + public function testGithubIssue39EncryptDecrypt() + { + $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); + $aes->enableContinuousBuffer(); + + $expected = '12345678901234567'; + $actual = ''; + + for ($i = 0, $strlen = strlen($expected); $i < $strlen; ++$i) + { + $actual .= $aes->decrypt($aes->encrypt($expected[$i])); + } + + $this->assertEquals($expected, $actual); + } +}