summaryrefslogtreecommitdiff
path: root/_test/tests/inc/blowfish.test.php
blob: 972df11f4b16a8df50a5ab745b33e44dd09a55b0 (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
<?php
/**
 * Test for blowfish encryption.
 */
class blowfish_test extends DokuWikiTest {
    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)
        );
    }

    // FS#1690 FS#1713
    public function testEncryptDecryptBinary() {
        $secret = '$%ÄüfuDFRR';
        $string = "this is\0binary because of\0zero bytes";
        $this->assertEquals(
            $string,
            PMA_blowfish_decrypt(PMA_blowfish_encrypt($string, $secret), $secret)
        );
    }
}