Generates a new key & saves it encrypted with a hashing strategy

@param string $name
@return string
@throws SecurityException
967562
public function generateKey($name)
    {
        if (strlen($name) === 0) {
            throw new SecurityException('Required name argument was empty', 1334215474);
        }
        $password = UtilityAlgorithms::generateRandomString($this->passwordGenerationLength);
        $this->persistKey($name, $password);
        return $password;
    }
1332375
public function crypto($name = null)
    {
        if ($name === null) {
            if ($this->_cryptoClass) {
                return $this->_cryptoClass;
            }
            throw new Exception(__d('cake_pdf', 'Crypto is not loaded'));
        }
        $config = [];
        if (is_array($name)) {
            $config = $name;
            $name = $name['className'];
        }

        $engineClassName = App::className($name, 'Pdf/Crypto', 'Crypto');
        if (!class_exists($engineClassName)) {
            throw new Exception(__d('cake_pdf', 'Pdf crypto "%s" not found', $name));
        }
        if (!is_subclass_of($engineClassName, 'CakePdf\Pdf\Crypto\AbstractPdfCrypto')) {
            throw new Exception(__d('cake_pdf', 'Crypto engine must extend "AbstractPdfCrypto"'));
        }
        $this->_cryptoClass = new $engineClassName($this);
        $this->_cryptoClass->config($config);

        return $this->_cryptoClass;
    }
854215
public function createNode($name)
    {
        $node = new \PAGI\Node\Node();
        return $node->setName($name)->setAgiClient($this);
    }
1271273
public function encryptNameId(XMLSecurityKey $key) : void
    {
        if ($this->nameId === null) {
            throw new \Exception('Cannot encrypt NameID, no NameID set.');
        }
        /* First create an XML representation of the NameID. */
        $doc = DOMDocumentFactory::create();
        $root = $doc->createElement('root');
        $doc->appendChild($root);
        $this->nameId->toXML($root);
        /** @var \DOMElement $nameId */
        $nameId = $root->firstChild;

        Utils::getContainer()->debugMessage($nameId, 'encrypt');

        /* Encrypt the NameID. */
        $enc = new XMLSecEnc();
        $enc->setNode($nameId);
        // @codingStandardsIgnoreStart
        $enc->type = XMLSecEnc::Element;
        // @codingStandardsIgnoreEnd

        $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
        $symmetricKey->generateSessionKey();
        $enc->encryptKey($key, $symmetricKey);

        /**
         * @var \DOMElement encryptedNameId
         * @psalm-suppress UndefinedClass
         */
        $this->encryptedNameId = $enc->encryptNode($symmetricKey);
        $this->nameId = null;
    }
1338622
public function addField(string $name) : self
    {
        // Generate field name
        $field_name = 'field_' . bin2hex(random_bytes(16));
        if (substr($name, -2) === '[]') {
            $field_name .= '[]';
        }

        // Field key must be unique
        if (isset($_SESSION[$this->key][$field_name])) {
            return $this->addField($name);
        }

        // Remove square brackets from original key (moved to generated key few lines above)
        if (substr($name, -2) === '[]') {
            $name = substr($name, 0, -2);
        }

        // Save
        $_SESSION[$this->key][$field_name] = trim($name);
        return $this;
    }
295687
public static function get($name)
    {
        if (!self::isExist($name)) return false;
        $value = $_COOKIE[Config::get('cookie_prefix') . $name];
        return Encry::decrypt($value);
    }
1175675
private static function createPassKey($key)
    {
        /**
         * ------------------------------------
         * Safe Sanitized hash
         * ------------------------------------
         */
        (is_null($key) || $key === false) && $key = '';
        // safe is use array or object as hash
        $serialize_key      = @serialize($key);
        if (!$serialize_key) {
            throw new \ErrorException(
                sprintf(
                    'Could not serialize input key of %s',
                    gettype($serialize_key)
                )
            );
        }

        /**
         * ------------------------------------
         * Set Key
         * ------------------------------------
         */

        $key       = pack('H*', self::hashStringContainer($serialize_key));
        return [
            $serialize_key,
            self::safeBase64Encode(str_pad($key, 24, "\0", STR_PAD_RIGHT))
        ];
    }
1178285
public function hash($input) {
		$hash = crypt($input, $this->getSalt());

		if (Utils::binaryStrlen($hash) != $this->getResultLength()) {
			throw new HashException("Error while generating Hash");
		}

		return $hash;
	}
12245
public static function getDIKey($name)
    {
        $name = str_replace(['/', '\\'], '.', $name);

        $name = StringNormalise::toDotSeparated($name);

        return strtolower(static::getPrefix() . '.' . $name);
    }
1148607
public static function create($name) {
    $parts = explode('\\', $name);
    $name_node = new NameNode();
    foreach ($parts as $i => $part) {
      $part = trim($part);
      if ($i > 0) {
        $name_node->append(Token::namespaceSeparator());
      }
      if ($part !== '') {
        $name_node->append(Token::identifier($part));
      }
    }
    return $name_node;
  }
331321
public static function newName($name)
    {
        if (file_exists($name)) {
            $extension = self::getFileExtension($name);
            $name = substr($name,0,(-strlen($extension)-1)) . '_' . sha1(uniqid(rand(), true)) . ".$extension";
        }
        return $name;
    }
265912
public function generate(): string
    {
        try {
            return DefuseKey::createNewRandomKey()->saveToAsciiSafeString();
        } catch(EnvironmentIsBrokenException $e) {
            throw new CryptoException($e->getMessage(), $e->getCode(), $e);
        }
    }
587851
public static function fromKey($name)
    {
        foreach (static::values() as $key => $enumInstance) {
            if ($enumInstance->getKey() === $name) {
                return $enumInstance;
            }
        }

        return null;
    }
424175
public static function CreateCookieName ($name = self::DEFAULT_CONNECTION_NAME) {
		$options = static::GetAuthCookieOptions($name);
		$cookie_save_dir	= $options['cookie_save_dir'];
		$cookie_name_prefix	= $options['cookie_name_prefix'];
		$cookie_name_safix	= $options['cookie_name_safix'];

		clearstatcache();
		for ($i = 0;$i < 100;$i++) {
			$cookie_name = sprintf('%s%s%s', $cookie_name_prefix, Hash::HmacString(rand(1, $i.microtime(true)).$cookie_name_prefix, rand(1, microtime(true)).$cookie_name_safix), $cookie_name_safix);
			if (!is_file(static::CreateCookieSavePath($cookie_name))) {
				return $cookie_name;
			}
		}

		return null;
	}
831543
public function getParametersWithKey($name)
    {
        $parameters = array();

        /** @var Parameter $parameter */
        foreach ($this->parameters as $parameter) {
            if ($parameter->getKey() == $name) {
                $parameters[] = $parameter;
            }
        }

        return $parameters;
    }
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];
    }
1110456
public function getItemKey($name): string
    {
        if (func_num_args() > 1)
            $name = func_get_args();

        if (is_array($name))
            return implode('|', $name);

        return (string) $name;
    }