Hi All
I'm trying to use the Crypt in Phalcon, which i have set in my multi-module app (#module). I have a function which creates a session and create a cookie with a token value (#session). The startup works fine, but when i would like to evaluate the key and token by $this->security->checkToken (#check) then it fails. if i set $cookies->useEncryption(false). then it works. I have checked the output from $xsrf_cookie->getValue() and it is equal to the $token string value, before encryption, which is set in the cookie. My experience in this field is low so any suggestions and ideas are welcome, thanks in advance.
BR
// #module
...
$di->set('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set('security', function () {
    $security = new Security();
// Set the password hashing factor to 12 rounds
    $security->setWorkFactor(12);
    return $security;
}, true);
$di->set('cookies', function () {
    $cookies = new Cookies();
    $cookies->useEncryption(true);
    return $cookies;
});
$di->set('crypt', function () {
    $crypt = new Crypt();
    $crypt->setKey('test');
    return $crypt;
});
...// #session
...
$auth_key_expire = time() + 15 * 60;
$this->session->set('auth', array(
    'id' => $User->id,
    'auth_key' => $this->security->getTokenKey(),
    'auth_key_expire' => $auth_key_expire
    ));
$token = $this->security->getToken();
$this->cookies->set('XSRF-TOKEN', $token, $auth_key_expire)->send();
...// #check
...
$auth = $this->session->get('auth');
$xsrf_cookie = ($this->cookies->has('XSRF-TOKEN')) ? $this->cookies->get('XSRF-TOKEN') : FALSE;
if($auth != FALSE && $xsrf_cookie != FALSE) {
    $equal_expire = ($auth['auth_key_expire'] == $xsrf_cookie->getExpiration()) ? TRUE : FALSE;
    $xsrf_token = $xsrf_cookie->getValue();
    $valid_token = $this->security->checkToken($auth['auth_key'],$xsrf_token,FALSE);
}
...