original_string: public function encrypt($xml, $nonce = null, $timestamp = null): string
      {
          try {
              $xml = $this->pkcs7Pad(str_random(16).pack('N', strlen($xml)).$xml.$this->appId, $this->blockSize);
  
              $encrypted = base64_encode(AES::encrypt(
                  $xml,
                  $this->aesKey,
                  substr($this->aesKey, 0, 16),
                  OPENSSL_NO_PADDING
              ));
              // @codeCoverageIgnoreStart
          } catch (Throwable $e) {
              throw new RuntimeException($e->getMessage(), self::ERROR_ENCRYPT_AES);
          }
          // @codeCoverageIgnoreEnd
  
          !is_null($nonce) || $nonce = substr($this->appId, 0, 10);
          !is_null($timestamp) || $timestamp = time();
  
          $response = [
              'Encrypt' => $encrypted,
              'MsgSignature' => $this->signature($this->token, $timestamp, $nonce, $encrypted),
              'TimeStamp' => $timestamp,
              'Nonce' => $nonce,
          ];
  
          //生成响应xml
          return XML::build($response);
      }
code: public function encrypt($xml, $nonce = null, $timestamp = null): string
      {
          try {
              $xml = $this->pkcs7Pad(str_random(16).pack('N', strlen($xml)).$xml.$this->appId, $this->blockSize);
  
              $encrypted = base64_encode(AES::encrypt(
                  $xml,
                  $this->aesKey,
                  substr($this->aesKey, 0, 16),
                  OPENSSL_NO_PADDING
              ));
              // @codeCoverageIgnoreStart
          } catch (Throwable $e) {
              throw new RuntimeException($e->getMessage(), self::ERROR_ENCRYPT_AES);
          }
          // @codeCoverageIgnoreEnd
  
          !is_null($nonce) || $nonce = substr($this->appId, 0, 10);
          !is_null($timestamp) || $timestamp = time();
  
          $response = [
              'Encrypt' => $encrypted,
              'MsgSignature' => $this->signature($this->token, $timestamp, $nonce, $encrypted),
              'TimeStamp' => $timestamp,
              'Nonce' => $nonce,
          ];
  
          //生成响应xml
          return XML::build($response);
      }
code_tokens: public function encrypt ( $ xml , $ nonce = null , $ timestamp = null ) : string { try { $ xml = $ this -> pkcs7Pad ( str_random ( 16 ) . pack ( 'N' , strlen ( $ xml ) ) . $ xml . $ this -> appId , $ this -> blockSize ) ; $ encrypted = base64_encode ( AES :: encrypt ( $ xml , $ this -> aesKey , substr ( $ this -> aesKey , 0 , 16 ) , OPENSSL_NO_PADDING ) ) ; // @codeCoverageIgnoreStart } catch ( Throwable $ e ) { throw new RuntimeException ( $ e -> getMessage ( ) , self :: ERROR_ENCRYPT_AES ) ; } // @codeCoverageIgnoreEnd ! is_null ( $ nonce ) || $ nonce = substr ( $ this -> appId , 0 , 10 ) ; ! is_null ( $ timestamp ) || $ timestamp = time ( ) ; $ response = [ 'Encrypt' => $ encrypted , 'MsgSignature' => $ this -> signature ( $ this -> token , $ timestamp , $ nonce , $ encrypted ) , 'TimeStamp' => $ timestamp , 'Nonce' => $ nonce , ] ; //生成响应xml return XML :: build ( $ response ) ; }
docstring: Encrypt the message and return XML.
  
  @param string $xml
  @param string $nonce
  @param int    $timestamp
  
  @return string
  
  @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
docstring_tokens: Encrypt the message and return XML .