Function __global->cms_base64_encode

Definitions

sources/global3.php

  • Encode a string using base64, but with additional options.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$data LONG_TEXT No No required parameter N/A N/A The data to encode
$url_safe boolean No No False N/A N/A Whether to output base64url format instead, which is URL (parameters only) and file safe
$hashed boolean No No False N/A N/A Whether to hash $data with SHA-256 first and then encode the hash
$salted boolean No No False N/A N/A Whether to salt the data for SHA-256 hashing using the site salt; ignored if $hashed is false

Returns

  • The base64 or base64url data
  • Type: SHORT_TEXT
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Encode a string using base64, but with additional options.
 *
 * @param  LONG_TEXT $data The data to encode
 * @param  boolean $url_safe Whether to output base64url format instead, which is URL (parameters only) and file safe
 * @param  boolean $hashed Whether to hash $data with SHA-256 first and then encode the hash
 * @param  boolean $salted Whether to salt the data for SHA-256 hashing using the site salt; ignored if $hashed is false
 * @return SHORT_TEXT The base64 or base64url data
 */

function cms_base64_encode(string $data, bool $url_safe = false, bool $hashed = false, bool $salted = false) : string