/** * @return string */ protected function createFormToken() { $token = StringGenerator::randomAlnum(128); $cacheKey = self::$formTokenApcCacheKey . $token; apc_store($cacheKey, true, self::$formTokenExpirationTime); return $token; }
public function __construct() { $this->setVariables(new ArrayCollection()); $this->setToken(StringGenerator::randomAlnum(self::TOKEN_LENGHT)); $this->generateExpirationDate(); }
/** * @param string $redirectUrl * @return string */ protected function createRedirectToken($redirectUrl) { $token = StringGenerator::randomAlnum(16); apc_store(self::$redirectTokenApcCacheKey . $token, $redirectUrl); return $token; }
public function testRandomUuid() { $string = StringGenerator::randomUuid(); $this->assertRegExp("/^[a-z0-9]{8,8}-[a-z0-9]{4,4}-[a-z0-9]{4,4}-[a-z0-9]{4,4}-[a-z0-9]{12,12}\$/", $string); }
/** * generate new token * by uniqId and time requested * @param null $namespace * @param int $length * @return string */ public static function generate($namespace = null, $length = 25) { $uniqValue = uniqid(rand(), true) . time(); $uniqValue .= !is_null($namespace) ? $namespace : ''; return strtoupper(sha1($uniqValue)) . StringGenerator::randomAlnum($length, true); }