Ejemplo n.º 1
0
 /**
  * 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');
 }
Ejemplo n.º 2
0
 /**
  * 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));
 }