Пример #1
0
 public function buildCryptSalt($salt, $iterations)
 {
     return '$6$rounds=' . Math::clip($iterations, 1000, 999999999) . '$' . $salt;
 }
Пример #2
0
 /**
  * Constructs and starts a new session.
  *
  * @param Storage $storage the storage to use - the storage engine for this storage must use
  * timestamps, encryption is optional but recommended
  * @param string $cookiePath the path for the session cookie
  * @param string $cookieDomain the domain for the session cookie
  * @param boolean $cookieSecure whether to transmit the session cookie via HTTPS only
  * @param boolean $cookieName the cookie name (default is SID)
  * @param CookieTransceiver $userCookieTransceiver the user cookie transceiver
  * @param CookieTransceiver $guestCookieTransceiver the guest cookie transceiver
  * @param int $duration the session duration in seconds (default is 1800 seconds)
  * @param float $garbageCollectorProbability the garbage collector probability (default is 0.01)
  * @throws InvalidArgumentException when the session could not be loaded
  */
 public function __construct(Storage $storage, $cookieName, $cookiePath, $cookieDomain, $cookieSecure, $userCookieTransceiver, $guestCookieTransceiver, $duration = 1800, $garbageCollectorProbability = 0.01)
 {
     if (!$storage->getEngine()->getUseTimestamps()) {
         throw new InvalidArgumentException('Storage engine for session storage needs to store timestamps');
     }
     $this->storage = $storage;
     $this->cookieName = $cookieName;
     $this->cookiePath = $cookiePath;
     $this->cookieDomain = $cookieDomain;
     $this->cookieSecure = $cookieSecure;
     $this->userCookieTransceiver = $userCookieTransceiver;
     $this->guestCookieTransceiver = $guestCookieTransceiver;
     $this->duration = $duration;
     $this->garbageCollectorProbability = Math::clip($garbageCollectorProbability, 0.0, 1.0);
 }