Пример #1
0
 public function getModel($name)
 {
     // If during the session class definitions has changed, this will throw an exception.
     try {
         return unserialize($this->get($name));
     } catch (Exception $e) {
         Dump::warn('Model definition changed during cookie period');
         return false;
     }
 }
Пример #2
0
 public function createHash($password)
 {
     // @see http://net.tutsplus.com/tutorials/php/understanding-hash-functions-and-keeping-passwords-safe/
     if (CRYPT_BLOWFISH !== 1) {
         Dump::warn('BLOWFISH algorithm not available for hashing, using MD5 instead');
         // Use MD5
         $algo = '$1';
         $cost = '';
         $unique_salt = $this->generateSecret(12);
     } else {
         // Use BLOWFISH
         $algo = '$2a';
         $cost = '$10';
         $unique_salt = $this->generateSecret(22);
     }
     $hash = crypt($password, $algo . $cost . '$' . $unique_salt);
     if (empty($hash)) {
         // TODO:
         throw new Exception('crypt() algorithm failed');
     }
     return $hash;
 }