Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_blowfish_test.php « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 234339abcda167bcc21795a27234bdd69d8ecf27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Test for blowfish encryption.
 *
 * @package phpMyAdmin-test
 */

/**
 * Tests core.
 */
require_once 'PHPUnit/Framework.php';

/**
 * Include to test.
 */
require_once './libraries/blowfish.php';

/**
 * Test java script escaping.
 *
 * @package phpMyAdmin-test
 */
class PMA_blowfish_test extends PHPUnit_Framework_TestCase
{
    public function testEncryptDecryptNumbers()
    {
        $secret = '$%ÄüfuDFRR';
        $string = '12345678';
        $this->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 = 'kO/kc4j/nyk=';
        $this->assertEquals($encrypted, PMA_blowfish_encrypt($decrypted, $secret));
    }

    public function testDecrypt()
    {
        $secret = '$%ÄüfuDFRR';
        $encrypted = 'kO/kc4j/nyk=';
        $decrypted = '12345678';
        $this->assertEquals($decrypted, PMA_blowfish_decrypt($encrypted, $secret));
    }

}
?>