public static function generateKey() { do { $salt = sha1(time() . mt_rand()); $newKey = substr($salt, 0, 40); } while (self::keyExists($newKey)); return $newKey; }