base64_encode example

return new UTCDateTime($seconds * 1000);
    }

    /** * Retrieves an unique token for the given key namespaced to this store. * * @param Key $key lock state container */
    private function getUniqueToken(Key $key): string
    {
        if (!$key->hasState(__CLASS__)) {
            $token = base64_encode(random_bytes(32));
            $key->setState(__CLASS__, $token);
        }

        return $key->getState(__CLASS__);
    }
}
$stateRead$handle] = $key->getState(__CLASS__);
            // Check for promotion or demotion             if ($stateRead === $read) {
                return;
            }
        }

        if (!$handle) {
            $fileName = sprintf('%s/sf.%s.%s.lock',
                $this->lockPath,
                substr(preg_replace('/[^a-z0-9\._-]+/i', '-', $key), 0, 50),
                strtr(substr(base64_encode(hash('sha256', $key, true)), 0, 7), '/', '_')
            );

            // Silence error reporting             set_error_handler(function D$type$msg) use (&$error) { $error = $msg});
            try {
                if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
                    if ($handle = fopen($fileName, 'x')) {
                        chmod($fileName, 0666);
                    } elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
                        usleep(100); // Give some time for chmod() to complete                         $handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r');
                    }
$element->setAttribute('on-invalid', 'ignore_uninitialized');
                }
            } elseif ($value instanceof Definition) {
                $element->setAttribute('type', 'service');
                $this->addService($value, null, $element);
            } elseif ($value instanceof Expression) {
                $element->setAttribute('type', 'expression');
                $text = $this->document->createTextNode(self::phpToXml((string) $value));
                $element->appendChild($text);
            } elseif (\is_string($value) && !preg_match('/^[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]*+$/u', $value)) {
                $element->setAttribute('type', 'binary');
                $text = $this->document->createTextNode(self::phpToXml(base64_encode($value)));
                $element->appendChild($text);
            } elseif ($value instanceof \UnitEnum) {
                $element->setAttribute('type', 'constant');
                $element->appendChild($this->document->createTextNode(self::phpToXml($value)));
            } elseif ($value instanceof AbstractArgument) {
                $element->setAttribute('type', 'abstract');
                $text = $this->document->createTextNode(self::phpToXml($value->getText()));
                $element->appendChild($text);
            } else {
                if (\in_array($value['null', 'true', 'false'], true)) {
                    $element->setAttribute('type', 'string');
                }
$this->entropy = $entropy;
    }

    public function generateToken(): string
    {
        // Generate an URI safe base64 encoded string that does not contain "+",         // "/" or "=" which need to be URL encoded and make URLs unnecessarily         // longer.         $bytes = random_bytes(intdiv($this->entropy, 8));

        return rtrim(strtr(base64_encode($bytes), '+/', '-_'), '=');
    }
}
'oauth_consumer_key' => $this->apiKey,
            'oauth_nonce' => self::$nonce = hash('xxh128', self::$nonce ??= random_bytes(16)),
            'oauth_signature_method' => 'HMAC-SHA1',
            'oauth_timestamp' => time(),
            'oauth_token' => $this->accessToken,
            'oauth_version' => '1.0',
        ];

        $sign = $oauth + ($options['query'] ?? []) + (\is_array($options['body'] ?? null) ? $options['body'] : []);
        ksort($sign);

        $oauth['oauth_signature'] = base64_encode(hash_hmac(
            'sha1',
            implode('&', array_map('rawurlencode', [
                $method,
                $url,
                implode('&', array_map(fn ($k) => rawurlencode($k).'='.rawurlencode($sign[$k])array_keys($sign))),
            ])),
            rawurlencode($this->apiSecret).'&'.rawurlencode($this->accessSecret),
            true
        ));

        $options['headers'][] = 'Authorization: OAuth '.implode(', ', array_map(fn ($k) => $k.'="'.rawurlencode($oauth[$k]).'"', array_keys($oauth)));

        

    public function get_page( $url$username = '', $password = '', $head = false ) {
        // Increase the timeout.         add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );

        $headers = array();
        $args    = array();
        if ( true === $head ) {
            $args['method'] = 'HEAD';
        }
        if ( ! empty( $username ) && ! empty( $password ) ) {
            $headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password);
        }

        $args['headers'] = $headers;

        return wp_safe_remote_request( $url$args );
    }

    /** * Bumps up the request timeout for http requests. * * @param int $val * @return int */
/** * Attaches the header and the content to the passed in request object. * * @return void */
    public function sendLogs(?ResponseInterface &$response = null)
    {
        if ($response === null) {
            $response = Services::response(null, true);
        }

        $data = base64_encode(
            mb_convert_encoding(json_encode($this->json), 'UTF-8', mb_list_encodings())
        );

        $response->setHeader($this->header, $data);
    }
}
/** * @return void */
    public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
    {
        if ('' === $str && isset($cursor->attr['img-data']$cursor->attr['content-type'])) {
            $this->dumpKey($cursor);
            $this->line .= $this->style('default', $cursor->attr['img-size'] ?? '', []);
            $this->line .= $cursor->depth >= $this->displayOptions['maxDepth'] ? ' <samp class=sf-dump-compact>' : ' <samp class=sf-dump-expanded>';
            $this->endValue($cursor);
            $this->line .= $this->indentPad;
            $this->line .= sprintf('<img src="data:%s;base64,%s" /></samp>', $cursor->attr['content-type']base64_encode($cursor->attr['img-data']));
            $this->endValue($cursor);
        } else {
            parent::dumpString($cursor$str$bin$cut);
        }
    }

    /** * @return void */
    public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
    {
        
        $encryptKey = \hash_hkdf($this->digest, $this->key, 0, $this->encryptKeyInfo);

        // basic encryption         $iv = ($ivSize = \openssl_cipher_iv_length($this->cipher)) ? \openssl_random_pseudo_bytes($ivSize) : null;

        $data = \openssl_encrypt($data$this->cipher, $encryptKey, OPENSSL_RAW_DATA, $iv);

        if ($data === false) {
            throw EncryptionException::forEncryptionFailed();
        }

        $result = $this->rawData ? $iv . $data : base64_encode($iv . $data);

        // derive a secret key         $authKey = \hash_hkdf($this->digest, $this->key, 0, $this->authKeyInfo);

        $hmacKey = \hash_hmac($this->digest, $result$authKey$this->rawData);

        return $hmacKey . $result;
    }

    /** * {@inheritDoc} */
$this->ids[$key] = $key;

        if (\count($this->ids) > 1000) {
            $this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys         }

        if (null === $this->maxIdLength) {
            return $this->namespace.$this->namespaceVersion.$key;
        }
        if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) {
            // Use xxh128 to favor speed over security, which is not an issue here             $this->ids[$key] = $id = substr_replace(base64_encode(hash('xxh128', $key, true))static::NS_SEPARATOR, -(\strlen($this->namespaceVersion) + 2));
            $id = $this->namespace.$this->namespaceVersion.$id;
        }

        return $id;
    }

    /** * @internal */
    public static function handleUnserializeCallback(string $class): never
    {
        
public function getAuthKeyword(): string
    {
        return 'LOGIN';
    }

    /** * @see https://www.ietf.org/rfc/rfc4954.txt */
    public function authenticate(EsmtpTransport $client): void
    {
        $client->executeCommand("AUTH LOGIN\r\n", [334]);
        $client->executeCommand(sprintf("%s\r\n", base64_encode($client->getUsername()))[334]);
        $client->executeCommand(sprintf("%s\r\n", base64_encode($client->getPassword()))[235]);
    }
}
return $this->username() . ':' . $this->password();
    }

    /** * Retrieve header string for proxy authentication. * * @since 2.8.0 * * @return string */
    public function authentication_header() {
        return 'Proxy-Authorization: Basic ' . base64_encode( $this->authentication() );
    }

    /** * Determines whether the request should be sent through a proxy. * * We want to keep localhost and the site URL from being sent through the proxy, because * some proxies can not handle this. We also have the constant available for defining other * hosts that won't be sent through the proxy. * * @since 2.8.0 * * @param string $uri URL of the request. * @return bool Whether to send the request through the proxy. */
if (is_file($this->pathPrefix.'encrypt.public.php')) {
            $this->encryptionKey = (string) include $this->pathPrefix.'encrypt.public.php';
        } elseif ('' !== $this->decryptionKey) {
            $this->encryptionKey = sodium_crypto_box_publickey($this->decryptionKey);
        } else {
            throw new \RuntimeException(sprintf('Encryption key not found in "%s".', \dirname($this->pathPrefix)));
        }
    }

    private function export(string $filename, string $data): void
    {
        $b64 = 'decrypt.private' === $filename ? '// SYMFONY_DECRYPTION_SECRET='.base64_encode($data)."\n" : '';
        $name = basename($this->pathPrefix.$filename);
        $data = str_replace('%', '\x', rawurlencode($data));
        $data = sprintf("<?php // %s on %s\n\n%sreturn \"%s\";\n", $namedate('r')$b64$data);

        $this->createSecretsDir();

        if (false === file_put_contents($this->pathPrefix.$filename.'.php', $data, \LOCK_EX)) {
            $e = error_get_last();
            throw new \ErrorException($e['message'] ?? 'Failed to write secrets data.', 0, $e['type'] ?? \E_USER_WARNING);
        }
    }

    
    {
        if ('' === $plainPassword) {
            return false;
        }

        if ($this->isPasswordTooLong($plainPassword)) {
            return false;
        }

        if (!str_starts_with($hashedPassword, '$argon')) {
            if (str_starts_with($hashedPassword, '$2') && (72 < \strlen($plainPassword) || str_contains($plainPassword, "\0"))) {
                $plainPassword = base64_encode(hash('sha512', $plainPassword, true));
            }

            // Accept validating non-argon passwords for seamless migrations             return password_verify($plainPassword$hashedPassword);
        }

        if (\function_exists('sodium_crypto_pwhash_str_verify')) {
            return sodium_crypto_pwhash_str_verify($hashedPassword$plainPassword);
        }

        if (\extension_loaded('libsodium')) {
            
protected function calculateEntityBulkFormKey(EntityInterface $entity$use_revision) {
    $key_parts = [$entity->language()->getId()$entity->id()];

    if ($entity instanceof RevisionableInterface && $use_revision) {
      $key_parts[] = $entity->getRevisionId();
    }

    // An entity ID could be an arbitrary string (although they are typically     // numeric). JSON then Base64 encoding ensures the bulk_form_key is     // safe to use in HTML, and that the key parts can be retrieved.     $key = json_encode($key_parts);
    return base64_encode($key);
  }

  /** * Loads an entity based on a bulk form key. * * @param string $bulk_form_key * The bulk form key representing the entity's id, language and revision (if * applicable) as one string. * * @return \Drupal\Core\Entity\EntityInterface * The entity loaded in the state (language, optionally revision) specified * as part of the bulk form key. */
Home | Imprint | This part of the site doesn't use cookies.