Пример #1
0
 /**
  * @inheritdoc
  */
 public function hash($unhashedValue, array $options = [], $pepper = "")
 {
     if (!isset($options["cost"])) {
         $options["cost"] = self::DEFAULT_COST;
     }
     return parent::hash($unhashedValue, $options, $pepper);
 }
Пример #2
0
 public static function hash($data, $field = False)
 {
     $hasher = new Hasher();
     if ($field) {
         if (empty($data[$field])) {
             throw new AuthEmptyPasswordError();
         }
         $data[$field] = $hasher->hash($data[$field]);
         return $data;
     } else {
         if (empty($data)) {
             throw new AuthEmptyPasswordError();
         }
         return $hasher->hash($data);
     }
 }
Пример #3
0
 /**
  */
 public function testHash()
 {
     $username = '******';
     $password = '******';
     $hashedPassword = $this->hasher->hash($username, $password);
     self::assertSame($hashedPassword, '2df63690f4e665f3584bed37e314945a4acf59dbebe99e75b3ae1e1fd24e1142873ba98d2bc6a104ef0a1f9629782b6a52914a2d7b3f657b963a1b22489541b1');
     $otherHasher = new Hasher('43321');
     $hashedPasswordWithOtherSalt = $otherHasher->hash($username, $password);
     self::assertNotEquals($hashedPassword, $hashedPasswordWithOtherSalt, 'The same passwords with different salts should have different hashes.');
 }
Пример #4
0
 /**
  * Get a shortened URL
  * 
  * @param string $url URL
  * @return string
  */
 public static function getShortURL($url)
 {
     $hash = Hasher::getHashFromURL($url);
     if (!$hash && $this->shorten) {
         $hash = Hasher::hash($url);
     }
     if ($hash) {
         return elgg_normalize_url(implode('/', array(PAGEHANDLER, $hash)));
     }
     return $url;
 }
Пример #5
0
 public function testHash()
 {
     $this->assertSame(sha1('test'), Hasher::hash(new HashMethod(HashMethod::SHA1), 'test'));
 }
 public function hashCode()
 {
     $hashCode = '';
     foreach ($this as $key => $value) {
         $hashCode .= self::$HASH_SIGNATURE . Hasher::hash($key) . '=>' . Hasher::hash($value);
     }
     return md5($hashCode);
 }