/** * Return a CSRF token. * * * @return string */ public function token() { if ($this->app['Session']->has('disco-csrf-token')) { return $this->app['Session']->get('disco-csrf-token'); } //if $this->app['Session']->set('disco-csrf-token', \Disco\manage\Manager::genRand(32)); return $this->app['Session']->get('disco-csrf-token'); }
/** * Hash with sha512. * Generate a new salt and hash the value with it, returning both the salt and hash. * * * @param string $value The value to hash using sha512. * @param int $saltLength The length of the salt to generate, defaults to 128. * * @return array An array with two keys, `salt` and `hash`, containing the salt and hash value respectivly. * */ public function hashAndGenerateNewSalt($value, $saltLength = 128) { $salt = \Disco\manage\Manager::genRand($saltLength); return array('salt' => $salt, 'hash' => $this->hash($value, $salt)); }