Enables encryption of the stream

@param $secret String the secret generated by the client, used to encrypt the stream
346099
public function enableAES($secret)
    {
        $this->secret = $secret;
        $this->encryptor = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CFB, '');
    }
1356278
function set_secret($secret = null)
    {
        // generate random hash and store in session
        if (!$secret) {
            if (!empty($_SESSION['auth_secret'])) {
                $secret = $_SESSION['auth_secret'];
            }
            else {
                $secret = rcube_utils::random_bytes(strlen($this->key));
            }
        }

        $_SESSION['auth_secret'] = $secret;
    }
489659
public function setAuthToken($token, $secret) {
		$this->authToken = $token;
		$this->authSecret = $secret;
		$this->f3->set('SESSION.dropbox.authToken', $this->authToken);
		$this->f3->set('SESSION.dropbox.authSecret', $this->authSecret);
	}
23076
public function getPassPhrase($secret) {
    $passPhrase = '';

    $chunks = explode('-',chunk_split($secret, 8, '-'));
    for($i = 0; $i <= sizeof($chunks); $i++) {
      if(trim($chunks[$i]) === '') {
        break;
      }
      $x = hexdec($chunks[$i]);
      $w[$i][1] = $x % $this->n;
      $w[$i][2] = ($x / $this->n + $w[$i][1]) % $this->n;
      $w[$i][3] = ($x / pow($this->n, 2) + $w[$i][2]) % $this->n;

      $passPhrase .= $this->dictionary[$w[$i][1]].' '.
                     $this->dictionary[$w[$i][2]].' '.
                     $this->dictionary[$w[$i][3]].' ';

    }
    return $passPhrase;
  }
974021
public static function encode($input, $secret = null) {
        // no input?
        if(!$input)
            return false;

        // run xor
        $xored = self::xor((string)$input, self::secret($secret));

        // output
        return self::base64encode($xored);
    }
219645
public function isValid($secret)
    {
        if (!extension_loaded('hash')) {
            // @codeCoverageIgnoreStart
            throw new \Exception('Hash extension not loaded');
            // @codeCoverageIgnoreEnd
        }

        list($algo, $sig) = explode("=", $this->signature);

        if (!in_array($algo, hash_algos(), true)) {
            throw new \Exception("Hash algorithm '$algo' is not supported.");
        }

        $hash = hash_hmac($algo, $this->rawBody, $secret);

        return (md5($sig) === md5($hash));
    }
1134958
public function addKey(string $kid, string $secret): void
    {
        $this->keys[$kid] = $secret;
    }
849730
static function lock($string, $key = null) {
        return openssl_encrypt($string, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }
265460
public static function setKey($key, $cipher = null)
    {
        static::$key = $key;

        if (!is_null($cipher)) {
            static::$cipher = $cipher;
        }
    }
71192
public function setSecure($secure = null)
    {
        if ($secure == 'tls') {
            $this->_protocol = 'tcp';
            $this->_secure = 'tls';
        } elseif ($secure == 'ssl') {
            $this->_protocol = 'ssl';
            $this->_secure = 'ssl';
        } else {
            $this->_protocol = 'tcp';
            $this->_secure = 'no';
        }
    }
163257
public static function setClientSecret($client_secret){
      if (!isset(self::$_config)){
        self::initialize();
      }
      self::$_config->configure(['CLIENT_SECRET' => $client_secret]); 
    }
277788
public function setToken($token, $secret)
    {
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string')
            //argument 2 must be a string
            ->test(2, 'string');
        
        $this->requestToken = $token;
        $this->requestSecret = $secret;
        
        return $this;
    }
1038409
public function encrypt($message)
	{
		$crypted = NULL;
		
		openssl_public_encrypt($message, $crypted, $this->publicKey);
		
		return base64_encode($crypted);
	}
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;
    }
17616
public static String decode(String content, String secret) {
        try {
            //1.构造密钥生成器，指定为AES算法,不区分大小写
            KeyGenerator keygen = KeyGenerator.getInstance("AES");
            //2.根据encodeRules规则初始化密钥生成器
            //生成一个256位的随机源,根据传入的字节数组
            keygen.init(256, new SecureRandom(secret.getBytes()));
            //3.产生原始对称密钥
            SecretKey original_key = keygen.generateKey();
            //4.获得原始对称密钥的字节数组
            byte[] raw = original_key.getEncoded();
            //5.根据字节数组生成AES密钥
            SecretKey key = new SecretKeySpec(raw, "AES");
            //6.根据指定算法AES自成密码器
            Cipher cipher = Cipher.getInstance("AES");
            //7.初始化密码器，第一个参数为加密(Encrypt_mode)或者解密(Decrypt_mode)操作，第二个参数为使用的KEY
            cipher.init(Cipher.DECRYPT_MODE, key);
            //8.将加密并编码后的内容解码成字节数组
            byte[] byte_content = new BASE64Decoder().decodeBuffer(content);
            byte[] byte_decode = cipher.doFinal(byte_content);
            return new String(byte_decode, StandardCharsets.UTF_8);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //如果有错就返加null
        return null;
    }
473484
public function setSecret($secret)
    {
        if (!$secret instanceof Seed) {
            $secret = new Seed($secret);
        }
        $this->secret = $secret;

        return $this;
    }
861920
public function hotp($secret, $counter)
    {
        if (!is_numeric($counter) || $counter < 0) {
            throw new \InvalidArgumentException('Invalid counter supplied');
        }
        
        $hash = hash_hmac(
                $this->algorithm,
                $this->getBinaryCounter($counter),
                $secret,
                true
        );
    
        return str_pad($this->truncate($hash), $this->digits, '0', STR_PAD_LEFT);
    }