GGenerate an encrypted key

@return string
482943
public static function make()
    {
        $salt = date('Y-m-d H:i:s', time() - 10000) . uniqid(rand(), true);

        $token = base64_encode(base64_encode(openssl_random_pseudo_bytes(6)) . $salt);

        return Str::slice(hash('sha256', $token), 1, 62);
    }
618452
public static function generateKey()
    {
        do {
            $salt = sha1(time() . mt_rand());
            $newKey = substr($salt, 0, 40);
        } // Already in the DB? Fail. Try again
        while (self::keyExists($newKey));

        return $newKey;
    }
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
1060342
public static function generateEncryptionKey(): EncryptionKey
    {
        // @codeCoverageIgnoreStart
        try {
            $secretKey = \random_bytes(\SODIUM_CRYPTO_STREAM_KEYBYTES);
        } catch (\Throwable $ex) {
            throw new CannotPerformOperation($ex->getMessage());
        }
        // @codeCoverageIgnoreEnd
        return new EncryptionKey(
            new HiddenString($secretKey)
        );
    }
684575
public function generateSecret()
    {
        $secret = bin2hex(random_bytes(20));
        $this->secret = password_hash($secret, PASSWORD_DEFAULT);

        return $secret;
    }
532144
public function createPrivateKey()
    {
        $rsa = new RSA();
        $rsa->setPrivateKeyFormat(RSA::PRIVATE_FORMAT_PKCS1);

        return $rsa->createKey($this->getPrivateKeySize())['privatekey'];
    }
165447
public function getPublicKey()
    {
        $res = \openssl_pkey_get_private($this->keyMaterial);
        $pubkey = \openssl_pkey_get_details($res);
        $public = \rtrim(
            \str_replace("\n", "\r\n", $pubkey['key']),
            "\r\n"
        );
        return new PublicKey($public);
    }
810410
public function generateRandomApiKey()
    {
        $this->_api_key_private = md5($this->_id . uniqid());

        $this->_api_key_public = $this->generateApiPublicKey();

        return $this;
    }
586933
public function getKey(): string
    {
        if ($this->key) {
            return $this->key;
        }

        if ($this->config->has('key')) {
            $key = Key::validate($this->config->get('key'), 'group');

            $this->key = $key;

            return $key;
        }

        $this->key = Key::sanitize($this->config->get('title'));

        return $this->key;
    }
1038819
public function getEncoded()
    {
        $data = serialize($this->data);
        if (function_exists('gzdeflate'))
        {
            $data = gzdeflate($data);
        }
        $data = base64_encode($data);
        $data .= $this->signature($data);
        return $data;
    }
1209078
public static function generateIdentityKeyPair()
    {
        $keyPair = Curve::generateKeyPair();
        $publicKey = new IdentityKey($keyPair->getPublicKey());
        $serialized = '0a21056e8936e8367f768a7bba008ade7cf58407bdc7a6aae293e2cb7c06668dcd7d5e12205011524f0c15467100dd6'.
                     '03e0d6020f4d293edfbcd82129b14a88791ac81365c';
        $serialized = pack('H*', $serialized);
        $identityKeyPair = new IdentityKeyPair($publicKey, $keyPair->getPrivateKey());

        return $identityKeyPair;
        // return new IdentityKeyPair(serialized=serialized)
    }
134971
public function generate()
	{
		$key = call_user_func_array('parent::generate', func_get_args());

		if ($this->hex === true) {
			$this->hex = false;
		}

		return $key;
	}
510262
public function generate() {
        $strong = false;
        $i = 0;

        while (!$strong && $this->maxTries > $i++) {
            $data = openssl_random_pseudo_bytes(32, $strong);
        }

        if (!$strong) {
            throw new RuntimeException('Could not generate private key');
        }

        // base64_encode to get a decent ascii compatible format, and trim ending ='s.
        $key = rtrim(base64_encode($data), '=');

        // We change +/ into -_ to avoid any human confusion with paths
        return strtr($key, '+/', '-_');
    }
640984
public function getEncryptionKey()
    {
        // initial key
        $securityKey = $this->securityKey;

        // append current session id
        $securityKey .= $this->httpSession()->getSessionId();

        // hash and return
        return hash('sha512', $securityKey);
    }
1231215
public function getKey(): string
    {
        if (starts_with($this->key, 'base64:')) {
            return base64_decode(mb_substr($this->key, 7));
        }

        return $this->key;
    }
919915
protected function keygen($length)
    {
        $key = '';
        for($i = 1; $i < $length; $i++) {
            $key .= mt_rand(0,9);
        }
        $key .= mt_rand(1,9);
        
        return $key;
    }
1226165
private function generateFromGeneric()
    {
        $ctypes = $this->app['config']->get('contenttypes');

        $translatables = array_filter(
            array_keys($this->translatables),
            function ($key) {
                return substr($key, 0, 21) === 'contenttypes.generic.' && substr($key, 21, 6) !== 'group.';
            }
        );

        foreach ($translatables as $key) {
            foreach ($ctypes as $ctname => $ctype) {
                $setkey = 'contenttypes.' . $ctname . '.text.' . substr($key, 21);
                $this->translation[$setkey] = isset($this->saved[$setkey]) ? $this->saved[$setkey] : '';
                if ($this->translation[$setkey] === '') {
                    $generic = Trans::__($key);
                    // If not translated, add hint
                    if ($generic !== $key) {
                        $replacement = [];
                        if (strpos($generic, '%contenttypes%') !== false) {
                            $replacement['%contenttypes%'] = $ctname;
                        } elseif (strpos($generic, '%contenttype%') !== false) {
                            $replacement['%contenttype%'] = $ctname;
                        }
                        $this->hints[$setkey] = Trans::__($key, $replacement);
                    }
                }
            }
        }
    }