PFinal\Wechat\Api::attemptEncrypt PHP Метод

attemptEncrypt() защищенный Метод

对响应给微信服务器的消息进行加密,自动识别是否需要加密,本次请求未加密时,数据原样返回
protected attemptEncrypt ( string $message ) : string
$message string
Результат string
    protected function attemptEncrypt($message)
    {
        //请求未加密时,回复明文内容
        if ($this->encryptType == static::ENCRYPT_TYPE_RAW) {
            return $message;
        }
        //加密
        if ($this->encryptType == static::ENCRYPT_TYPE_AES) {
            $timestamp = time();
            $nonce = uniqid();
            return $this->encryptMsg($message, $timestamp, $nonce);
        }
        throw new WechatException('unknown encrypt type: ' . $this->encryptType);
    }