1<?php
2
3/**
4 * Tests the auth_decrypt and auth_encrypt-functions
5 */
6class auth_encryption_test extends DokuWikiTest
7{
8    function testDeEncrypt()
9    {
10        $data = "OnA28asdfäakgß*+!\"+*";
11        $secret = "oeaf1öasdöflk§";
12        $this->assertEquals($data, auth_decrypt(auth_encrypt($data, $secret), $secret));
13    }
14
15    /**
16     * Try to decode a known secret. This one has been created with phpseclib Version 2
17     */
18    function testCompatibility()
19    {
20        $secret = 'secret';
21        $plain = 'This is secret';
22        $crypt = '837e9943623a34fe340e89024c28f4e9be13bbcacdd139801ef16a27bffa7714';
23        $this->assertEquals($plain, auth_decrypt(hex2bin($crypt), $secret));
24    }
25}
26