Compute the U value.

@param string $encryptionKey
@return string
169052
protected function computeUValue($encryptionKey)
    {
        $revision = $this->revision;
        // Algorithm 4: Computing the encryption dictionary’s U (user password)
        // value (Security handlers of revision 2)
        if ($revision < 3) {
            return $this->arcfour($encryptionKey, $this->padding);
        }

        // Algorithm 5: Computing the encryption dictionary’s U (user password)
        // value (Security handlers of revision 3 or greater)

        // a) Create an encryption key based on the user password string, as described
        //    in "Algorithm 2: Computing an encryption key".
        //    passed through $encryptionKey-parameter

        // b) Initialize the MD5 hash function and pass the 32-byte padding string shown
        //    in step (a) of "Algorithm 2: Computing an encryption key" as input to
        //    this function.
        $s = $this->padding;

        // c) Pass the first element of the file’s file identifier array (the value of
        //    the ID entry in the document’s trailer dictionary; see Table 15) to the
        //    hash function and finish the hash.
        $s .= $this->fileIdentifier;
        $s = md5($s, true);

        // d) Encrypt the 16-byte result of the hash, using an RC4 encryption function
        //    with the encryption key from step (a).
        $s = $this->arcfour($encryptionKey, $s);

        // e) Do the following 19 times: Take the output from the previous invocation
        //    of the RC4 function and pass it as input to a new invocation of the function;
        //    use an encryption key generated by taking each byte of the original encryption
        //    key obtained in step (a) and performing an XOR (exclusive or) operation
        //    between that byte and the single-byte value of the iteration counter (from 1 to 19).
        $length = strlen($encryptionKey);
        for($i = 1; $i <= 19; $i++) {
            $tmp = array();
            for($j = 0; $j < $length; $j++) {
                $tmp[$j] = ord($encryptionKey[$j]) ^ $i;
                $tmp[$j] = chr($tmp[$j]);
            }
            $s = $this->arcfour(join('', $tmp), $s);
        }

        // f) Append 16 bytes of arbitrary padding to the output from the final invocation
        //    of the RC4 function and store the 32-byte result as the value of the U entry
        //    in the encryption dictionary.
        return $s . str_repeat("\0", 16);
    }
976824
public static function getNumeric($key, $default = null)
    {
        $value = ini_get($key);

        return $value === false || $value === '' ? $default : $value + 0;
    }
752032
protected function _normalizeKey($key)
    {
        try {
            return $this->_normalizeString($key);
        } catch (InvalidArgumentException $e) {
            throw $this->_createOutOfRangeException($this->__('Invalid key'), null, $e, $key);
        }
    }
964284
protected function parseKey(&$key) {
        $key   =  trim($key);
        if(!is_numeric($key) && !preg_match('/[,\'\"\*\(\)\[.\s]/',$key)) {
           $key = '['.$key.']';
        }
        return $key;   
    }
1036893
function decrypt($ciphertext)
    {
        if ($this->k <= 0) {
            return false;
        }

        $ciphertext = str_split($ciphertext, $this->k);
        $ciphertext[count($ciphertext) - 1] = str_pad($ciphertext[count($ciphertext) - 1], $this->k, chr(0), STR_PAD_LEFT);

        $plaintext = '';

        switch ($this->encryptionMode) {
            case self::ENCRYPTION_NONE:
                $decrypt = '_raw_encrypt';
                break;
            case self::ENCRYPTION_PKCS1:
                $decrypt = '_rsaes_pkcs1_v1_5_decrypt';
                break;
            //case self::ENCRYPTION_OAEP:
            default:
                $decrypt = '_rsaes_oaep_decrypt';
        }

        foreach ($ciphertext as $c) {
            $temp = $this->$decrypt($c);
            if ($temp === false) {
                return false;
            }
            $plaintext.= $temp;
        }

        return $plaintext;
    }
1332085
private function getKey ( $key = NULL ) {
        if ($key === NULL) {
            $key = $this->__keyName;
            return $this->getClassKey() . '_' . $this->$key;
        }
        return $this->getClassKey() . '_' . $key;
    }
883844
public function normalizeKey(string $key): string
    {
        $key = strtr(strtolower(trim($key)), '_', '-');

        if (strpos($key, 'http-') === 0) {
            $key = substr($key, 5);
        }

        return $key;
    }
581797
private static function formatParamsKey($key): string
    {
        if (\is_string($key) && \strpos($key, ':') === false) {
            return ':' . $key;
        }

        return $key;
    }
1038622
public function getIntegerValue($key)
    {
        $value = $this->get($key);
        if ($value === null) {
            return null;
        }
        return (integer)$value;
    }
571331
public function getValue(string $key): float
    {
        return $this->handle->zScore($this->name, $key);
    }
1215162
public function get_crypto_key($key)
    {
        // Bomb out if the requested key does not exist
        if (!array_key_exists($key, $this->prop) || empty($this->prop[$key])) {
            rcube::raise_error(array(
                'code' => 500, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Request for unconfigured crypto key \"$key\""
            ), true, true);
        }

        return $this->prop[$key];
    }
111023
public function decrypt($encrypted, $key)
	{
		if (empty($encrypted))
			return null;

		list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2);

		if ($identifier !== self::IDENTIFIER)
			throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier);

		// Split the input into its parts
		$cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input);
		$originalSize = intval($cipherSplit[0]);
		$iv = cryptoHelpers::toNumbers($cipherSplit[1]);
		$cipherText = $cipherSplit[2];

		// Set up encryption parameters
		$cipherIn = cryptoHelpers::toNumbers($cipherText);
		$keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key));
		$keyLength = count($keyAsNumbers);

		$decrypted = AES::decrypt(
			$cipherIn,
			$originalSize,
			AES::modeOfOperation_CBC,
			$keyAsNumbers,
			$keyLength,
			$iv
		);

		// Byte-array to text.
		$hexDecrypted = cryptoHelpers::toHex($decrypted);
		$retVal = pack("H*", $hexDecrypted);

		return $retVal;
	}
307145
public function strlen(string $key): int
    {
        return $this->handle->rawCommand('hstrlen', [$this->name, $key]);
    }
160143
public function getAsActualType($key)
    {
        $type = $this->getType($key);
        $value = null;
        switch ($type) {
            case self::BOOLEAN: {
                $value = $this->getBoolean($key);
                break;
            }
            case self::INT: {
                $value = $this->getInt($key);
                break;
            }
            case self::FLOAT: {
                $value = $this->getFloat($key);
                break;
            }
            case self::STRING: {
                $value = $this->getString($key);
                break;
            }
            case self::DATE: {
                $value = $this->getDate($key);
                break;
            }
            case self::XML: {
                $value = $this->getXML($key);
                break;
            }
            case self::DATA: {
                $value = $this->getData($key);
                break;
            }
            case self::DATA_ARRAY: {
                $value = $this->getArray($key);
                break;
            }
            case self::OBJECT: {
                $value = $this->getArray($key);
                break;
            }
        }

        return $value;
    }
565258
public function decrypt($ciphertxt, $key = '', $ttl = 0)
    {
        if (empty($ciphertxt)) return $ciphertxt;
        if (empty($key)) $key = md5($this->key);
    
        $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
        $ikey ="-x6g6ZWm2G9g_vr0Bo.pOq3kRIxsZ6rm";
        $knum = 0;$i = 0;
        $tlen = @strlen($ciphertxt);
        while(isset($key{$i})) $knum +=ord($key{$i++});
        $ch1 = @$ciphertxt{$knum % $tlen};
        $nh1 = strpos($chars,$ch1);
        $ciphertxt = @substr_replace($ciphertxt,'',$knum % $tlen--,1);
        $ch2 = @$ciphertxt{$nh1 % $tlen};
        $nh2 = @strpos($chars,$ch2);
        $ciphertxt = @substr_replace($ciphertxt,'',$nh1 % $tlen--,1);
        $ch3 = @$ciphertxt{$nh2 % $tlen};
        $nh3 = @strpos($chars,$ch3);
        $ciphertxt = @substr_replace($ciphertxt,'',$nh2 % $tlen--,1);
        $nhnum = $nh1 + $nh2 + $nh3;
        $mdKey = substr(md5(md5(md5($key.$ch1).$ch2.$ikey).$ch3),$nhnum % 8,$knum % 8 + 16);
        $tmp = '';
        $j=0; $k = 0;
        $tlen = @strlen($ciphertxt);
        $klen = @strlen($mdKey);
        for ($i=0; $i<$tlen; $i++) {
            $k = $k == $klen ? 0 : $k;
            $j = strpos($chars,$ciphertxt{$i})-$nhnum - ord($mdKey{$k++});
            while ($j<0) $j+=64;
            $tmp .= $chars{$j};
        }
        $tmp = str_replace(array('-','_','.'), array('+','/','='), $tmp);
        $tmp = trim(base64_decode($tmp));
        
        if (preg_match("/\d{10}_/s", substr($tmp,0,11))){
            if ($ttl > 0 && (time() - substr($tmp,0,11) > $ttl)) {
                $tmp = null;
            }else{
                $tmp = substr($tmp, 11);
            }
        }
        return $tmp;
    }
1060342
public static function generateEncryptionKey(): EncryptionKey
    {
        // @codeCoverageIgnoreStart
        try {
            $secretKey = \random_bytes(\SODIUM_CRYPTO_STREAM_KEYBYTES);
        } catch (\Throwable $ex) {
            throw new CannotPerformOperation($ex->getMessage());
        }
        // @codeCoverageIgnoreEnd
        return new EncryptionKey(
            new HiddenString($secretKey)
        );
    }
681598
protected function _normalizeKey($key)
    {
        if (!is_string($key) && !is_numeric($key))
            $key = md5(Std\flatten($key));

        return $key;
    }