Generate a version 5 UUID based on the SHA-1 hash of a namespace
identifier (which is a UUID) and a name (which is a string).

@param string $ns   The UUID namespace in which to create the named UUID
@param string $name The name to create a UUID for
545284
public static function uuid5(string $ns, string $name): self
    {
        if (class_exists(RhumsaaUuid::class)) {
            return new self(RhumsaaUuid::uuid5($ns, $name));
        }

        return new self(RamseyUuid::uuid5($ns, $name));
    }
1237074
def uuid5(namespace, name):
    """"""
    from hashlib import sha1
    hash = sha1(namespace.bytes + name).digest()
    return UUID(bytes=hash[:16], version=5)
1225833
public function hasAnnotation($name)
    {
        $result = false;

        if (!string_ends_with($name, 'Annotation')) $name .= 'Annotation';

        foreach ($this->annotations as $annotation)
        {
            $class = get_class($annotation);

            if (string_starts_with($class, "\\") && !string_starts_with($name, "\\"))
                $name = "\\" . $name;
            elseif (!string_starts_with($class, "\\") && string_starts_with($name, "\\"))
                $name = substr($name, 1);

            if (string_ends_with($class, $name))
            {
                $result = true;
                break;
            }
        }

        return $result;
    }
711029
public static function generateClassName($name)
    {
        $name = str_replace("-", "_", $name);

        if (strstr($name, "\\")) {
            $composedName = "";
            foreach (explode("\\", $name) as $namespace) {
                $namespace = Inflector::underscore($namespace);
                $namespace = Inflector::classify($namespace);
                $composedName .= $namespace . "\\";
            }
        } else {
            $name = Inflector::underscore($name);
            $name = Inflector::classify($name);
        }

        $suffix = self::getClassNameSuffix();
        if (!preg_match("/$suffix$/", $name)) {
            $name .= $suffix;
        }

        if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $name)) {
            throw new Exception(sprintf("We could not generate a valid PHP classname from %s", $name));
        }

        return $name;
    }
1291765
def uuid3(namespace, name):
    """"""
    import md5
    hash = md5.md5(namespace.bytes + name).digest()
    return UUID(bytes=hash[:16], version=3)
459465
public function ns($nameSpace)
    {
        // If ! exist try to load a configuration file 
        if ( !isset($this->nameSpaces[$nameSpace]) ) {
            // short sanitize of nameSpace
            if (!filter_var( $nameSpace,FILTER_VALIDATE_REGEXP, 
                array('options'=>array('regexp' => '/^[\w]+$/')))) {
                    throw new InvalidArgumentException("Invalid configuration name.",400);
            }
            $this->nameSpaces[$nameSpace] = new ContextNameSpace($this->loadArrayFromIniFile($nameSpace));
        }
        
        return $this->nameSpaces[$nameSpace];
    }
140451
public function regenerateToken($name = null)
    {
        $this->initialize();

        $name                 = $this->hashName($name);
        $this->tokens[$name]  = $this->getUniqueToken();

        if (!isset($_SESSION[$this->key]) || !is_array($_SESSION[$this->key])) {
            $_SESSION[$this->key] = [];
        }

        $_SESSION[$this->key][$name] = $this->tokens[$name];

        return $this->tokens[$name];
    }
792462
public function setEosTokenName(string $name) : BasicLexer
    {
        if (strlen($name) == 0) {
            throw new \InvalidArgumentException('The name of the EOS token must be not empty.');
        }

        $this->eosTokenName = $name;

        return $this;
    }
1193425
public static function create(string $name, int $lifetime = 300): string
    {
        $token = sha1(microtime());
        $tokenData = [
            'token' => $token,
            'time' => time(),
            'lifetime' => $lifetime
        ];
        Session::set($name, $tokenData, self::$namespace);
        return $token;
    }
1304014
private static function fromString($name)
    {
        $components = self::calculateComponents($name);

        $nameParsed = \implode('-', $components);
        if (!self::isValid($nameParsed)) {
            throw new \InvalidArgumentException('Invalid UUID string: ' . $name);
        }

        return [
            self::TIME_LOW                  => \sprintf('%08s', $components[0]),
            self::TIME_MID                  => \sprintf('%04s', $components[1]),
            self::TIME_HI_AND_VERSION       => \sprintf('%04s', $components[2]),
            self::CLOCK_SEQ_HI_AND_RESERVED => \sprintf('%02s', \substr($components[3], 0, 2)),
            self::CLOCK_SEQ_LOW             => \sprintf('%02s', \substr($components[3], 2)),
            self::NODE                      => \sprintf('%012s', $components[4]),
        ];
    }
1276845
protected function createClassName(string $name): string
    {
        $result = str_replace('_', ' ', $name);

        return str_replace(' ', '', ucwords($result));
    }
1170778
public static function fromString($name)
    {
        $nameParsed = str_replace(array('urn:', 'uuid:', '{', '}', '-'), '', $name);

        // We have stripped out the dashes and are breaking up the string using
        // substr(). In this way, we can accept a full hex value that doesn't
        // contain dashes.
        $components = array(
            substr($nameParsed, 0, 8),
            substr($nameParsed, 8, 4),
            substr($nameParsed, 12, 4),
            substr($nameParsed, 16, 4),
            substr($nameParsed, 20),
        );
        $nameParsed = implode('-', $components);

        if (!self::isValid($nameParsed)) {
            throw new InvalidArgumentException('Invalid UUID string: ' . $name);
        }

        $fields = array(
            'time_low' => sprintf('%08s', $components[0]),
            'time_mid' => sprintf('%04s', $components[1]),
            'time_hi_and_version' => sprintf('%04s', $components[2]),
            'clock_seq_hi_and_reserved' => sprintf('%02s', substr($components[3], 0, 2)),
            'clock_seq_low' => sprintf('%02s', substr($components[3], 2)),
            'node' => sprintf('%012s', $components[4]),
        );

        return new self($fields);
    }
894481
protected function generateCsrfToken($name) {
    // generate token and store in session
    $token = base64_encode(openssl_random_pseudo_bytes(32));
    $this->getSession()->set(self::CSRF_TOKEN_PARAM.'_'.$name, $token);

    // set token in response
    $response = $this->getResponse();
    $response->setValue(self::CSRF_TOKEN_PARAM, $token);
  }
1309288
public static function uuid3(string $ns, string $name): self
    {
        if (class_exists(RhumsaaUuid::class)) {
            return new self(RhumsaaUuid::uuid3($ns, $name));
        }

        return new self(RamseyUuid::uuid3($ns, $name));
    }
950406
public function get_namespace($name = null)
    {
        $ns = $this->namespace;

        if ($name) {
            // an alias for BC
            if ($name == 'prefix') {
                $name = 'prefix_in';
            }

            return isset($ns[$name]) ? $ns[$name] : null;
        }

        unset($ns['prefix_in'], $ns['prefix_out']);

        return $ns;
    }
735461
public function setNodeName( $name )
	{
		if( $this->nodeName == (string) $name )
			return FALSE;
		$this->nodeName = (string) $name;
		return TRUE;
	}
624037
public function setName($name)
    {
        $name = strtolower($name);

        //Check for everything except letters and dashes.  Throw exception if any are found.
        if (preg_match("/[^a-z\-0-9\.]/", $name)) {
            throw new InvalidArgumentException(
                'Page names can only contain letters, numbers, dots, and dashes.'
                . ' No spaces. This page name is invalid: ' . $name
            );
        }

        $this->name = $name;
    }