Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Encodes data with MIME base64
<?php base64_encode(string $string): string
<?php $serialized = serialize($value);
return $this->connection instanceof PostgresConnection
? base64_encode($serialized)
: $serialized;
}
<?php $result = serialize($value);
if ($this->connection instanceof PostgresConnection && str_contains($result, "\0")) {
$result = base64_encode($result);
}
return $result;
<?php throw new EncryptException('Could not encrypt the data.');
}
$iv = base64_encode($iv);
$tag = base64_encode($tag ?? '');
$mac = self::$supportedCiphers[strtolower($this->cipher)]['aead']
<?php }
$iv = base64_encode($iv);
$tag = base64_encode($tag ?? '');
$mac = self::$supportedCiphers[strtolower($this->cipher)]['aead']
? '' // For AEAD-algorithms, the tag / MAC is returned by openssl_encrypt...
<?php throw new EncryptException('Could not encrypt the data.');
}
return base64_encode($json);
}
<?php $this->components->info('Environment successfully encrypted.');
$this->components->twoColumnDetail('Key', $keyPassed ? $key : 'base64:'.base64_encode($key));
$this->components->twoColumnDetail('Cipher', $cipher);
$this->components->twoColumnDetail('Encrypted file', $encryptedFile);
<?php protected function generateRandomKey()
{
return 'base64:'.base64_encode(
Encrypter::generateKey($this->laravel['config']['app.cipher'])
);
}
<?php {
$expiresAt = Carbon::now()->addHours(12);
return new Cookie('laravel_maintenance', base64_encode(json_encode([
'expires_at' => $expiresAt->getTimestamp(),
'mac' => hash_hmac('sha256', $expiresAt->getTimestamp(), $key),
])), $expiresAt, config('session.path'), config('session.domain'));
}
<?php public function withBasicAuth(string $username, string $password)
{
return $this->withToken(base64_encode("$username:$password"), 'Basic');
}
<?php return [
'sent' => $this->sent,
'data' => $hasAttachments ? base64_encode(serialize($this->data)) : $this->data,
'hasAttachments' => $hasAttachments,
];
}
<?php return [
'hasAttachments' => $hasAttachments,
'sentMessage' => $hasAttachments ? base64_encode(serialize($this->sentMessage)) : $this->sentMessage,
];
}
<?php public function encode()
{
return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(json_encode($this->toArray())));
}
<?php protected function getDefaultPayload($data)
{
$payload = [
'payload' => base64_encode($data),
'last_activity' => $this->currentTime(),
];
<?php $bytes = random_bytes($bytesSize);
$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}
return $string;
<?php public static function toBase64($string): string
{
return base64_encode($string);
}