src/includes/classes/Core/Utils/Rijndael256.php
public function decrypt(string $base64, string $key = ''): string
    {
        if (!isset($base64[0])) {
            return $string = '';
        } elseif (!$key && !($key = $this->App->Config->©encryption['©key'])) {
            throw $this->c::issue('Missing encryption key.');
        }
        $regex = // Matches a valid encryption.

          '/^'.// Beginning of the strong.
            '~r2'.// Required RIJNDAEL 256 marker.
            '\:(?<iv>[a-zA-Z0-9]{'.$this->iv_size.'})'.// Required IV.
            '(?:\:(?<sha1>[a-zA-Z0-9]{40}))?'.// Optional checksum.
            '\|(?<e>.+)'.// Encrypted string (not empty).
          '$/s'; // End of string.

        if (!($e = $this->c::base64UrlSafeDecode($base64))) {
            return $string = ''; // Not possible.
        }
        if (!preg_match($regex, $e, $iv_sha1_e)) {
            return $string = ''; // Not possible.
        }
        if (!empty($iv_sha1_e['sha1']) && $iv_sha1_e['sha1'] !== sha1($iv_sha1_e['e'])) {
            return $string = ''; // Invalid checksum; automatic failure.
        }
        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 (!is_string($string = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $iv_sha1_e['e'], MCRYPT_MODE_CBC, $iv_sha1_e['iv'])) || !isset($string[0])) {
            throw $this->c::issue('String decryption failed; `$string` is NOT a string, or it has no length.');
        }
        if (!strlen($string = preg_replace('/^~r2\|/', '', $string, 1, $r2)) || !$r2) {
            return $string = ''; // Missing packed component identifier.
        }
        return $string = $this->c::mbRTrim($string, "\0\4"); // See: <http://www.asciitable.com/>.
    }
public function decrypt(string $base64, string $key = ''): string
    {
        if (!isset($base64[0])) {
            return $string = '';
        } elseif (!$key && !($key = $this->App->Config->©encryption['©key'])) {
            throw $this->c::issue('Missing encryption key.');
        }
        $regex = // Matches a valid encryption.

          '/^'.// Beginning of the strong.
            '~r2'.// Required RIJNDAEL 256 marker.
            '\:(?<iv>[a-zA-Z0-9]{'.$this->iv_size.'})'.// Required IV.
            '(?:\:(?<sha1>[a-zA-Z0-9]{40}))?'.// Optional checksum.
            '\|(?<e>.+)'.// Encrypted string (not empty).
          '$/s'; // End of string.

        if (!($e = $this->c::base64UrlSafeDecode($base64))) {
            return $string = ''; // Not possible.
        }
        if (!preg_match($regex, $e, $iv_sha1_e)) {
            return $string = ''; // Not possible.
        }
        if (!empty($iv_sha1_e['sha1']) && $iv_sha1_e['sha1'] !== sha1($iv_sha1_e['e'])) {
            return $string = ''; // Invalid checksum; automatic failure.
        }
        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 (!is_string($string = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $iv_sha1_e['e'], MCRYPT_MODE_CBC, $iv_sha1_e['iv'])) || !isset($string[0])) {
            throw $this->c::issue('String decryption failed; `$string` is NOT a string, or it has no length.');
        }
        if (!strlen($string = preg_replace('/^~r2\|/', '', $string, 1, $r2)) || !$r2) {
            return $string = ''; // Missing packed component identifier.
        }
        return $string = $this->c::mbRTrim($string, "\0\4"); // See: <http://www.asciitable.com/>.
    }
RIJNDAEL 256 decryption with a URL-safe base64 unwrapper.

@since 150424 Initial release.

@param string $base64 String to decrypt (URL-safe base64).
@param string $key    Encryption key (required always).

@return string Decrypted string; or empty string on failure.