MD4 Encryption.

@param string $input

@return string

@see https://secure.php.net/manual/en/ref.hash.php
420351
protected function md4Encrypt($input)
    {
        $input = $this->convertTo16bit($input);

        return function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input);
    }
643296
protected function decodeSingleHeader($input)
    {
        // For each encoded-word...
        while (preg_match('/(=\?([^?]+)\?(q|b)\?([^?]*)\?=)((\s+)=\?)?/i', $input, $matches)) {
            $encoded = $matches[1];
            $charset = $matches[2];
            $encoding = $matches[3];
            $text = $matches[4];
            $space = isset($matches[6]) ? $matches[6] : '';

            switch (strtolower($encoding)) {
                case 'b':
                    $text = $this->decodeContentTransfer($text, 'base64');
                    break;

                case 'q':
                    $text = str_replace('_', ' ', $text);
                    preg_match_all('/=([a-f0-9]{2})/i', $text, $matches);
                    foreach ($matches[1] as $value) {
                        $text = str_replace('='.$value, chr(hexdec($value)), $text);
                    }
                    break;
            }

            $text = $this->charset->decodeCharset($text, $this->charset->getCharsetAlias($charset));
            $input = str_replace($encoded.$space, $text, $input);
        }

        return $input;
    }
97107
public static function toKey($input)
    {
        // Remove spaces and dashes, then convert to lower case.
        $input = self::toUnderscoreSeparated($input);
        $input = strtolower($input);

        return $input;
    }
604554
public function decrypt($input)
    {
        if (! $input) {
            return $input;
        }

        $methods = $this->getEncryptionMethods();
        if (':' == $input[0]) {
            list($empty, $mkey, $base64) = explode(':', $input, 3);

            if (! isset($methods[$mkey])) {
                $error = sprintf("Encryption method '%s' not defined in projec.ini.", $mkey);
                throw new \Gems_Exception_Coding($error);
            }

            $method = $methods[$mkey];
        } else {
            $mkey   = 'mcrypt';
            $base64 = $input;
            $method = $mkey;
        }

        $decoded = base64_decode($base64);
        if ('mcrypt' == $method) {
            $output = $this->decryptMcrypt($decoded);
        } elseif ('null' == $method) {
            $output = $base64;
        } else {
            $output = $this->decryptOpenSsl($decoded, $method);
        }

        if (false === $output) {
            return $input;
        } else {
            return $output;
        }
    }
94543
protected function _fromBase64url($input)
    {
        $remainder = strlen($input) % 4;
        if ($remainder)
        {
            $padlen = 4 - $remainder;
            $input .= str_repeat('=', $padlen);
        }

        return base64_decode(strtr($input, '-_', '+/'));
    }
914994
public static function hash($input)
    {
        if (Symphony::Log()) {
            Symphony::Log()->pushDeprecateWarningToLog('SHA1::hash()', 'PBKDF2::hash()', array(
                'message-format' => __('The use of `%s` is strongly discouraged due to severe security flaws.'),
            ));
        }
        return sha1($input);
    }
1021142
public static function hash($input, $rounds = 7)
    {
        $salt = "";
        $salt_chars = array_merge(
            range('A', 'Z'), 
            range('a', 'z'), 
            range(0, 9)
        );

        for ($i = 0; $i < 22; $i++) {
            $salt .= $salt_chars[array_rand($salt_chars)];
        }

        return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt);
    }
1278464
public function decrypt($input)
    {
        // Decode the IV + data
        $input = base64_decode($input);
        // Remove the IV
        $iv = substr($input, 0, Cipher::IV_SIZE);
        // Return Decrypted Data
        return openssl_decrypt(substr($input, Cipher::IV_SIZE), "AES-256-CBC", $this->secretKey, 0, $iv);
    }
196438
public static function parseIPv4($input)
    {
        $parts = explode('.', $input);
        if ($parts[count($parts) - 1] === '') {
            array_pop($parts);
        }
        
        if ($parts === []) {
            $ipv4 = '';
        } elseif (count($parts) > 4) {
            $ipv4 = (string)$input;
        } else {
            $numbers = [];
            foreach ($parts as $i => $part) {
                if ($part === '') {
                    $ipv4 = (string)$input;
                    break;
                }
                $n = self::parseIPv4Number($part);
                if ($n === false) {
                    $ipv4 = (string)$input;
                    break;
                }
                if ($n > 255 && $i !== count($parts) - 1) {
                    $ipv4 = false;
                }
                $numbers[] = $n;
            }
            
            if (!isset($ipv4)) {
                $ipv4 = array_pop($numbers);
                if ($ipv4 >= pow(256, 4 - count($numbers))) {
                    $ipv4 = false;
                } else {
                    foreach ($numbers as $counter => $n) {
                        $ipv4 += $n * pow(256, 3 - $counter);
                    }
                }
            }
        }
        
        return $ipv4;
    }
843444
private function fromFlattenedSerializationRecipientToSerialization($input)
    {
        $recipient = [];
        foreach (['header', 'encrypted_key'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipient[$key] = $input[$key];
            }
        }
        $recipients = [
            'ciphertext' => $input['ciphertext'],
            'recipients' => [$recipient],
        ];
        foreach (['protected', 'unprotected', 'iv', 'aad', 'tag'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipients[$key] = $input[$key];
            }
        }

        $this->log(LogLevel::INFO, 'JWE in Flattened JSON Serialization mode loaded.');

        return $recipients;
    }
809792
private function encryptBlock($input, $key)
    {
        if (!$input && !$key) {
            return '';
        }

        $this->prepareCipher($key);
        $result = mcrypt_generic($this->mcrypt, $input);
        mcrypt_generic_deinit($this->mcrypt);

        return $result;
    }
779383
private function captureUserAndPassword(Input $input)
    {
        $text = trim(preg_replace('|\W+|', ' ', $input->text));

        return explode(' ', $text);
    }
729527
protected function hash($input, $alphabet): string
    {
        $hash = '';
        $alphabetLength = \mb_strlen($alphabet);

        do {
            $hash = \mb_substr($alphabet, $this->math->intval($this->math->mod($input, $alphabetLength)), 1).$hash;

            $input = $this->math->divide($input, $alphabetLength);
        } while ($this->math->greaterThan($input, 0));

        return $hash;
    }
205564
public static function encrypt($input, $cryptKey)
    {
        return base64_encode(
            mcrypt_encrypt(
                MCRYPT_RIJNDAEL_256, 
                md5($cryptKey), 
                $input, 
                MCRYPT_MODE_CBC, 
                md5(
                    md5($cryptKey)
                )
            )
        );
    }
130984
public function genSalt($input = null)
    {
        if (!$input) {
            $input = $this->_getRandomBytes(3);
        }

        // Hash identifier
        $identifier = '_';

        // Cost factor - must be between 1 and 16777215
        $costFactor = min(max($this->_iterationCount, 1), 0xffffff);
        // Should be odd to avoid revealing weak DES keys
        if (($costFactor % 2) == 0) {
            --$costFactor;
        }

        // Salt string
        $salt = $this->_encode64($input, 3);

        // _CCCCSSSS
        return $identifier . $this->_encodeInt24($costFactor) . $salt;
    }
623389
public static function urlsafeB64Decode($input)
    {
        $remainder = strlen($input) % 4;

        if ($remainder) {
            $pad_length = 4 - $remainder;
            $input .= str_repeat('=', $pad_length);
        }

        return base64_decode(strtr($input, '-_', '+/'));
    }
24828
private static function ucs4array_ucs4($input)
    {
        $output = '';
        foreach ($input as $v) {
            $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
        }
        return $output;
    }