Exemplo n.º 1
0
 /**
  * Retrieve the CSRF token for the current request.
  *
  * @return string The CSRF token
  */
 private static function token()
 {
     if (static::$token !== null) {
         return static::$token;
     }
     $token = Str::random(32);
     // Store the new token
     Session::set(self::SESSION_KEY, $token);
     return static::$token = $token;
 }
Exemplo n.º 2
0
 /**
  * Tests that the output of random strings is truly random.
  *
  * @covers Molovo\Str\Str::random
  */
 public function testRandomStringUniqueness()
 {
     $strings = [];
     $i = 0;
     while ($i <= 100) {
         $strings[] = Str::random(10);
         $i++;
     }
     verify(count(array_unique($strings)))->equals(count($strings));
 }