src/includes/classes/Core/Utils/Rijndael256.php
public function encrypt(string $string, string $key = '', bool $sha1 = true): string
    {
        if (!isset($string[0])) {
            return $base64 = ''; // Nothing to do.
        } elseif (!$key && !($key = $this->App->Config->©encryption['©key'])) {
            throw $this->c::issue('Missing encryption key.');
        }
        $string = '~r2|'.$string; // `RIJNDAEL 256` identifier.

        if (strlen($key = (string) substr($key, 0, $this->key_size)) < $this->key_size) {
            throw $this->c::issue(sprintf('Key too short. Minimum length: `%1$s`.', $this->key_size));
        }
        if (strlen($iv = $this->c::randomKey($this->iv_size, false)) < $this->iv_size) {
            throw $this->c::issue(sprintf('IV too short. Minimum length: `%1$s`.', $this->iv_size));
        }
        if (!is_string($e = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv)) || !isset($e[0])) {
            throw $this->c::issue('String encryption failed; `$e` is not a string; or it has no length.');
        }
        $e = '~r2:'.$iv.($sha1 ? ':'.sha1($e) : '').'|'.$e; // Pack components.

        return $base64 = $this->c::base64UrlSafeEncode($e);
    }
public function encrypt(string $string, string $key = '', bool $sha1 = true): string
    {
        if (!isset($string[0])) {
            return $base64 = ''; // Nothing to do.
        } elseif (!$key && !($key = $this->App->Config->©encryption['©key'])) {
            throw $this->c::issue('Missing encryption key.');
        }
        $string = '~r2|'.$string; // `RIJNDAEL 256` identifier.

        if (strlen($key = (string) substr($key, 0, $this->key_size)) < $this->key_size) {
            throw $this->c::issue(sprintf('Key too short. Minimum length: `%1$s`.', $this->key_size));
        }
        if (strlen($iv = $this->c::randomKey($this->iv_size, false)) < $this->iv_size) {
            throw $this->c::issue(sprintf('IV too short. Minimum length: `%1$s`.', $this->iv_size));
        }
        if (!is_string($e = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv)) || !isset($e[0])) {
            throw $this->c::issue('String encryption failed; `$e` is not a string; or it has no length.');
        }
        $e = '~r2:'.$iv.($sha1 ? ':'.sha1($e) : '').'|'.$e; // Pack components.

        return $base64 = $this->c::base64UrlSafeEncode($e);
    }
RIJNDAEL 256 encryption with a URL-safe base64 wrapper.

@since 150424 Initial release.

@param string $string String to encrypt.
@param string $key    Encryption key (required always).
@param bool   $sha1   Defaults to `true` (recommended).

@return string Encrypted string (URL-safe base64).