Make a control key with the string containing datas

@param string $data data
@param string $controlType type of control 'md5', 'crc32' or 'strlen'
@return string control key
@access private
770368
function _hash($data, $controlType)
    {
        switch ($controlType) {
        case 'md5':
            return md5($data);
        case 'crc32':
            return sprintf('% 32d', crc32($data));
        case 'strlen':
            return sprintf('% 32d', strlen($data));
        default:
            return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
        }
    }
154077
public  function decryptByPublicKey($data) {
		$pu_key =  openssl_pkey_get_public($this->pubkey);
		$decrypted = "";
		$data = self::urlsafe_b64decode($data);

		openssl_public_decrypt($data,$decrypted,$pu_key);//公钥解密

		return $decrypted;
	}
967604
private function makeSignature($data)
    {
        $signature = '';
        $this->initOpenSSL();
        if (!openssl_sign($data, $signature, $this->privateKey, 'sha256')) {
            throw new SignatureException(openssl_error_string());
        }
        return $signature;
    }
770260
public static function secureData($data, string $type, bool $htmlentities)
    {
        $currentClass = get_called_class();
        
        if (is_array($data)) {
            foreach ($data as $key => $val) {
                unset($data[$key]);

                $key = $currentClass::secureData($key, gettype($key), true);
                $val = $currentClass::secureData($val, $type, $htmlentities);

                $data[$key] = $val;
            }

            return $data;
        }

        try {
            return $currentClass::secureKnownType($data, $type);
        } catch (Exception $ex) {
            if ($ex->getCode() !== self::ERR_SECURE_KNOWN_TYPE_FILTER_NOT_MANAGED) {
                throw new Exception($ex->getMessage(), $ex->getCode());
            }
            //Else : Use securise like if it's a text type
        }

        return $currentClass::secureUnknownType($data, $type, $htmlentities);
    }
390347
public function htmlDecode($data)
    {
        switch (gettype($data)) {
            case 'array':
                foreach ($data as $key => $value) {
                    $data[$key] = $this->htmlDecode($value);
                }

                break;
            case 'object':
                $data = clone $data;

                foreach ($data as $key => $value) {
                    $data->$key = $this->htmlDecode($value);
                }

                break;
            case 'string':
            default:
                $data = html_entity_decode($data, ENT_QUOTES, 'UTF-8');

                break;
        }

        return $data;
    }
89874
public String decryptStrFromBcd(String data, KeyType keyType, Charset charset) {
		return StrUtil.str(decryptFromBcd(data, keyType, charset), charset);
	}
163250
public function encrypt($data)
    {
        try {
            return openssl_encrypt($data, self::$algorithm, self::$pass);
        } catch (\Exception $e) {
            return $data;
        }
    }
402422
public function make_sign($data){
        /*去空*/
        $data=array_filter($data);
        /*签名步骤一：按字典序排序参数*/
        ksort($data);
        $string_a=http_build_query($data);
        $string_a=urldecode($string_a);

        /*签名步骤二：在string后加入KEY*/
        $config=$this->config;

        $string_sign_temp=$string_a."&key=".$config['key'];
        /*签名步骤三：MD5加密*/
        $sign = md5($string_sign_temp);
        /*签名步骤四：所有字符转为大写*/
        $result=strtoupper($sign);
        return $result;
    }
775812
protected function hasKeyLikeType(Data $data): bool
    {
        return $data->isScalar() || $data->isConvertibleToString() || $data->isHashable();
    }
1352219
public function encodeArray($data) {
        $d = array();
        foreach ($data as $key => $value) {
            if (is_string($key))
                $key = htmlspecialchars($key);
            if (is_string($value))
                $value = htmlspecialchars($value);
            elseif (is_array($value))
                $value = self::encodeArray($value);
            $d[$key] = $value;
        }
        return $d;
    }
866924
public function encrypt(string $data, string $password): string
    {
        $iv = $this->generateInitializationVector();
        $encryptedData = openssl_encrypt($data, self::CYPHER, $password, self::OPTIONS, $iv);
        if (false === $encryptedData) {
            $messages = [];
            while ($message = openssl_error_string()) {
                $messages[] = $message;
            }

            throw new CryptException('openssl_encrypt returned an error: '.implode(', ', $messages));
        }

        return $encryptedData.':'.bin2hex($iv);
    }
1207766
public static function encrypt(string $data, string $password): string
    {
        // Generate IV of appropriate size.
        $iv = self::generateIv();
        // Derive key from password
        $key = self::hash($iv, $password);
        // Encrypt the given data
        $cyphertext = openssl_encrypt($data, self::CIPHER, $key, OPENSSL_RAW_DATA, $iv);

        if ($cyphertext === false) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException('Encryption library: Encryption (symmetric) of content failed: ' . openssl_error_string());
            // @codeCoverageIgnoreEnd
        }
        // Checksum : Create a keyed hash for the encrypted data
        $checksum = self::hash($iv . $cyphertext, $key);
        // concat all the elements in the final encrypted string
        $encrypted = $iv . $checksum . $cyphertext;

        return $encrypted;
    }
1304820
public function getDerivedKey($type)
    {
        if ($this->_masterKey === null) {
            throw new CryptException(['getDerivedKey for `:type` type Failed: master key is not set', 'type' => $type]);
        }

        return md5($this->_masterKey . ':' . $type);
    }
1371219
public static function decrypt($data) : string {
      $crypter = new Crypter();

      return $crypter->decrypt($data, self::getAppKey());
    }
363314
public static function decrypt($data = '', $key = ''): string
    {
        $key = md5(empty($key) ? \Yii::$app->getRequest()->cookieValidationKey : $key);
        $data = str_replace(['-', '_'], ['+', '/'], $data);
        $mod4 = strlen($data) % 4;
        if ($mod4) {
            $data .= substr('====', $mod4);
        }
        $data = base64_decode($data);
        $expire = substr($data, 0, 10);
        $data = substr($data, 10);
        
        if ($expire > 0 && $expire < time()) {
            return '';
        }
        $x = 0;
        $len = strlen($data);
        $l = strlen($key);
        $char = $str = '';
        
        for ($i = 0; $i < $len; $i++) {
            if ($x == $l) {
                $x = 0;
            }
            $char .= substr($key, $x, 1);
            $x++;
        }
        
        for ($i = 0; $i < $len; $i++) {
            if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
                $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
            } else {
                $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
            }
        }
        
        return base64_decode($str);
    }
1117697
function decryptSimple($data) {
		$result = '';
		$data=base64_decode(str_replace(array('-', '_'),array('+', '/'),$data));
		for($i=0; $i<strlen($data); $i++) {
			$char = substr($data, $i, 1);
			$keychar = substr($this->encPassword, ($i % strlen($this->encPassword))-1, 1);
			$char = chr(ord($char)-ord($keychar));
			$result.=$char;
		}
		return $result;
	}
659375
public function decryptECB($data) {
		return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, self::BLOB_ENCRYPTION_KEY, self::pad($data), MCRYPT_MODE_ECB);
	}