Phalcon\Test\Unit\CryptTest::testCryptEncryptBase64 PHP Method

testCryptEncryptBase64() public method

Tests the encryption base 64
Since: 2014-10-17
Author: Nikolaos Dimopoulos ([email protected])
    public function testCryptEncryptBase64()
    {
        $this->specify("encryption base 64does not return correct results", function () {
            $crypt = new Crypt();
            $crypt->setPadding(Crypt::PADDING_ANSI_X_923);
            $key = substr('phalcon notice 13123123', 0, 16);
            $expected = 'https://github.com/phalcon/cphalcon/issues?state=open';
            $encrypted = $crypt->encryptBase64($expected, substr($key, 0, 16));
            $actual = $crypt->decryptBase64($encrypted, $key);
            expect($actual)->equals($expected);
            $encrypted = $crypt->encryptBase64($expected, $key, true);
            $actual = $crypt->decryptBase64($encrypted, $key, true);
            expect($actual)->equals($expected);
        });
    }