decrypt

@param string $str
@param string $secret default 'ePHP'
@return string
325115
public static function decryptG($str, $secret = 'ePHP')
    {
        if (!$str) {
            return false;
        }

        $key = md5($secret . "30f7384ac1");

        $ciphertext_raw = \ePHP\Misc\Func::safe_b64decode($str);
        return openssl_decrypt($ciphertext_raw, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
    }
684305
public static function altEncrypt($str, $pass = '')
    {
        /**
         * if empty values return null
         */
        if (!$str) {
            return null;
        }

        /**
         * ------------------------------------
         * Safe Sanitized hash
         * ------------------------------------
         */
        (is_null($pass) || $pass === false) && $pass = '';
        // safe is use array or object as hash
        $pass = Util::maybeSerialize($pass);
        if (!$pass) {
            $pass = sha1($pass);
        }

        // make an array values -> use key acb
        $str = serialize(array('acb' => $str));
        // rotate 13
        $str = pack('a*', Util::rotate($str.sha1(sha256::hash($pass)), 13));

        /**
         * Doing safe encode base 64
         */
        $str = Util::safeBase64Encode($str);

        /**
         * ------------------------------------
         * Doing convert string
         * ------------------------------------
         */
        $str_arr  = str_split($str);
        $add = 0;
        $div = strlen($str) / strlen($pass);
        $new_pass = '';
        while ($add <= $div) {
            $new_pass .= $pass;
            $add++;
        }
        $pass_arr = str_split($new_pass);
        $ascii = '';
        foreach ($str_arr as $key => $asc) {
            $pass_int = ord($pass_arr[$key]);
            $str_int = ord($asc);
            $int_add = $str_int + $pass_int;
            $ascii .= chr(($int_add+strlen($str)));
        }
        $ascii = trim(Util::safeBase64Encode($ascii));

        /**
         * ------------------------------------
         * Inject Result of with sign
         * ------------------------------------
         */
        if (strlen($ascii) > 10) {
            return substr_replace($ascii, '_aCb=', 10, 0);
        } else {
            return substr_replace($ascii, '_aCb=', 2, 0);
        }
    }
49449
private static function xor($input, $secret = null) {
        // perform xor
        $inputSize = strlen($input);
        $secretSize = strlen($secret);
        for($y = 0, $x = 0; $y < $inputSize; $y++, $x++) {
            if($x >= $secretSize)
                $x = 0;

            $input[$y] = $input[$y] ^ $secret[$x];
        }

        // output
        return $input;
    }
132712
public function encrypt($str = null, $key = null)
    {
        if (!is_null($key)) {
            $this->setSalt($key);
        }
        srand((double)microtime()*1000000);
        $key_encrypt    = md5(rand(0,32000));
        $count          = 0;
        $tmp            = '';
        for ($ctr=0;$ctr<strlen($str);$ctr++) {
            if ($count==strlen($key_encrypt)) {
                $count=0;
            }
            $tmp.= substr($key_encrypt,$count,1).(substr($str,$ctr,1) ^ substr($key_encrypt,$count,1) );
            $count++;
        }
        return base64_encode(self::getEncryptionKey($tmp));
    }
740443
public function decryptByConfig($str)
    {
        if ($this->isSingle()) {
            if ($security_key = $this->getConfigByName('security_key')) {
                $str = $this->decrypt($str, hex2bin(md5($security_key)));
            }
            return $str;
        }
        return '';
    }
544586
function decrypt (str) {
    var decipher = crypto.createDecipher(algorithm, key)
      , dec = decipher.update(str, to, from) + decipher.final(from)
    return dec;
  }
1262708
public static function decrypt($str, $key='', $vi='')
    {
        if (!extension_loaded('openssl')) {
            throw new \Exception("You must be install openssl.so. The extension.", 1);
        }
    	if (empty($key)) {
    		$key = self::getKey();
    	}
    	if (empty($vi)) {
    		$vi = self::getVi();
    	}
    	$data = hex2bin($str);//十六进制转二进制
        $decrypted = openssl_decrypt($data, self::getCipherMethod(), $key, OPENSSL_RAW_DATA, $vi);
        return $decrypted;
    }
630054
public function getCode($secret, $timeSlice = null)
    {
        if ($timeSlice === null) {
            $timeSlice = floor(time() / 30);
        }

        $secretkey = $this->_base32Decode($secret);

        // Pack time into binary string
        $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
        // Hash it with users secret key
        $hm = hash_hmac('SHA1', $time, $secretkey, true);
        // Use last nipple of result as index/offset
        $offset = ord(substr($hm, -1)) & 0x0F;
        // grab 4 bytes of the result
        $hashpart = substr($hm, $offset, 4);

        // Unpak binary value
        $value = unpack('N', $hashpart);
        $value = $value[1];
        // Only 32 bits
        $value = $value & 0x7FFFFFFF;

        $modulo = pow(10, $this->_codeLength);
        return str_pad($value % $modulo, $this->_codeLength, '0', STR_PAD_LEFT);
    }
657305
protected function decrypt($encryptedString)
    {
        $iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);

        return mcrypt_decrypt($this->cipher, $this->secretKey, $encryptedString, $this->cipherMode, $iv);
    }
193304
static function dn_decode($str)
    {
        $str = str_pad(strtr($str, '-_', '+/'), strlen($str) % 4, '=', STR_PAD_RIGHT);
        return base64_decode($str);
    }
864198
public static function decrypt($str,$key) {
        $str = self::ed($str,$key);
        $v = "";
		$len = strlen($str);
        for ($i=0;$i<$len;$i++){
         $md5 = substr($str,$i,1);
         $i++;
         $v .= (substr($str,$i,1) ^ $md5);
        }
        $data   =    $v;
        $expire = substr($data,0,10);
        if($expire > 0 && $expire < time()) {
            return '';
        }
        $data   = substr($data,10);
        return $data;
    }
328100
public function encrypt(string $str): string
    {
        return openssl_encrypt($str, self::CIPHER_METHOD, $this->key, 0, $this->getIv());
    }
169470
public static function decrypt($str, $key) {
        if ($str == "") {
            return "";
        }
        $data   =    self::_des($key,$str,0);
        $expire = substr($data,0,10);
        if($expire > 0 && $expire < time()) {
            return '';
        }
        $data   = substr($data,10);
        return $data;
    }
477896
private function parseCookies($str) {  
	    
	    if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}

	    $jar 	 = [];
		$headers = explode("\n", trim($str));

		foreach($headers as $header) {

			if(preg_match('/^set-cookie: /i', $header)) {
				
				$cookie = [];

				//Match name and value
				preg_match('/^set-cookie: ([^=]+)=([^;]+)/i', $header, $match);

				if(count($match) === 3) {
					
					$cookie['name']  = $match[1];
					$cookie['value'] = $match[2];
				
					//Match expires
					$cookie['expires'] = null;

					preg_match('/; expires=([^;]+)/i', $header, $match);

					if(count($match) === 2) {
						$cookie['expires'] = strtotime(urldecode(trim($match[1])));
					}

					//Match domain
					$cookie['domain'] = null;

					preg_match('/; domain=([^;]+)/i', $header, $match);

					if(count($match) === 2) {
						$cookie['domain'] = urldecode(trim($match[1]));
					}

					//Match secure
					$cookie['secure'] = false;

					preg_match('/; secure/i', $header, $match);

					if(count($match) === 1) {
						$cookie['secure'] = true;
					}

					//Match httponly
					$cookie['httponly'] = false;

					preg_match('/; httponly/i', $header, $match);

					if(count($match) === 1) {
						$cookie['httponly'] = true;
					}

					//Add cookie to the jar
					if(count($cookie) > 0) {
						$jar[] = $cookie;
					}
				}
			}
		}

		return $jar;
	}
977210
public static final String decrypt(String secretKey, String encryptedText) {
        if (encryptedText == null) {
            return null;
        }
        if (encryptedText.startsWith("$CRYPT::")) { //$NON-NLS-1$
            byte[] decoded = Base64.decodeBase64(encryptedText.substring(8));
            Cipher cipher;
            try {
                SecretKeySpec skeySpec = keySpecFromSecretKey(secretKey);
                
                cipher = Cipher.getInstance("AES"); //$NON-NLS-1$
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
                throw new RuntimeException(e);
            }
            try {
                return new String(cipher.doFinal(decoded));
            } catch (IllegalBlockSizeException | BadPaddingException e) {
                throw new RuntimeException(e);
            }
        } else {
            return encryptedText;
        }
    }
817905
function decrypt($str){
        //AES, 128 模式加密数据 CBC
        $str = base64_decode($str);
        $screct_key = base64_decode($this->key);
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), 1);
        $encrypt_str =  mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_CBC);
        $encrypt_str = trim($encrypt_str);

        $encrypt_str = stripPKSC7Padding($encrypt_str);
        return $encrypt_str;

    }
39286
function encrypt (str) {
    var cipher = crypto.createCipher(algorithm, key)
      , crypted = cipher.update(str, from, to) + cipher.final(to)
    return crypted;
  }