From da36b5c91ef81fd422661dc164e14c65ba077278 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 1 Mar 2016 16:30:36 -0600 Subject: [PATCH] RC2: fix issue with decrypting --- phpseclib/Crypt/RC2.php | 2 +- tests/Unit/Crypt/RC2Test.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 86e53c51..0f34880d 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -514,7 +514,7 @@ class Crypt_RC2 extends Crypt_Base return $result; } - return parent::encrypt($ciphertext); + return parent::decrypt($ciphertext); } /** diff --git a/tests/Unit/Crypt/RC2Test.php b/tests/Unit/Crypt/RC2Test.php index 430b69c8..2fa2c0d3 100644 --- a/tests/Unit/Crypt/RC2Test.php +++ b/tests/Unit/Crypt/RC2Test.php @@ -120,5 +120,8 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase $result = bin2hex($rc2->encrypt(pack('H*', $plaintext))); $this->assertEquals($result, $ciphertext, "Failed asserting that $plaintext yielded expected output in $engineName engine"); + + $result = bin2hex($rc2->decrypt(pack('H*', $ciphertext))); + $this->assertEquals($result, $plaintext, "Failed asserting that decrypted result yielded $plaintext as a result in $engineName engine"); } }