From 385efeb63ac8a0e33d8fc6a7c9889a9929e6877b Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Fri, 25 Jan 2008 09:34:21 +0000 Subject: [PATCH] testcase for blowfish de- and encryption --- test/AllTests.php | 2 ++ test/PMA_blowfish_test.php | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/PMA_blowfish_test.php diff --git a/test/AllTests.php b/test/AllTests.php index a49f98e29..29cc7ec37 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -32,6 +32,7 @@ require_once './test/PMA_transformation_getOptions_test.php'; require_once './test/PMA_STR_sub_test.php'; require_once './test/PMA_generateCommonUrl_test.php'; //require_once './test/PMA_arrayWalkRecursive_test.php'; +require_once './test/PMA_blowfish_test.php'; class AllTests { @@ -59,6 +60,7 @@ class AllTests $suite->addTestSuite('PMA_STR_sub_test'); $suite->addTestSuite('PMA_generate_common_url_test'); //$suite->addTestSuite('PMA_arrayWalkRecursive_test'); + $suite->addTestSuite('PMA_blowfish_test'); return $suite; } } diff --git a/test/PMA_blowfish_test.php b/test/PMA_blowfish_test.php new file mode 100644 index 000000000..64e749af3 --- /dev/null +++ b/test/PMA_blowfish_test.php @@ -0,0 +1,59 @@ +assertEquals($string, + PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)); + } + + public function testEncryptDecryptChars() + { + $secret = '$%ÄüfuDFRR'; + $string = 'abcDEF012!"§$%&/()=?`´"\',.;:-_#+*~öäüÖÄÜ^°²³'; + $this->assertEquals($string, + PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)); + } + + public function testEncrypt() + { + $secret = '$%ÄüfuDFRR'; + $decrypted = '12345678'; + $encrypted = 'p0nz15awFT4='; + $this->assertEquals($encrypted, PMA_blowfish_encrypt($decrypted, $secret)); + } + + public function testDecrypt() + { + $secret = '$%ÄüfuDFRR'; + $encrypted = 'p0nz15awFT4='; + $decrypted = '12345678'; + $this->assertEquals($decrypted, PMA_blowfish_decrypt($encrypted, $secret)); + } + +} +?>