Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. execute enc command from QtProgram

execute enc command from QtProgram

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 291 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • lincolnL Offline
    lincolnL Offline
    lincoln
    wrote on last edited by
    #1

    Hi guys, I have the following question, I want to encrypt a file with openssl, but it doesn't give me any result, I get the message that it was encrypted, but in the Qt output panel, I get an invalid command.
    Any suggestion of how I could do it would be appreciated, I am using QProcess and Openssl 1.1 for it, below I leave the code, thanks in advance.

    code:

    #include "mainwindow.h"
    #include "./ui_mainwindow.h"
    
    #include <QProcess>
    #include <QMessageBox>
    
    MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent), ui(new Ui::MainWindow)
    {
      ui->setupUi(this);
    
    
    }
    
    MainWindow::~MainWindow()
    {
      delete ui;
    }
    
    
    void MainWindow::on_pushButton_clicked()
    {
      QProcess *proc=new QProcess(this);
      QStringList argv;
      argv.append(" enc -des-cbc -a -in C:/Users/Lincoln/Desktop/test.txt -pass pass:123");
      argv.append(" -out C:/Users/Lincoln/Desktop/test.enc");
      bool res=proc->startDetached("D:/OpenSSL-Win64/bin/openssl.exe",argv);
      if(res)
        QMessageBox::information(this,qApp->applicationName(),"Archivo encriptado");
      else
        QMessageBox::critical(this,qApp->applicationName(),"Hubo un error");
    }
    
    

    c76f3633-d429-47e3-84e1-57781399001a-image.png

    Note that I get an encrypted file, but below it says something else.

    Solitary wolf

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You construct the argv incorrectly so its tries to run enc as an app and that fails.
      Each parameter should be added on its own like.

      QStringList arguments;
      arguments << "enc" << "-des-cbc" << "-a" and so on;

      https://doc.qt.io/qt-5/qprocess.html

      1 Reply Last reply
      3
      • lincolnL Offline
        lincolnL Offline
        lincoln
        wrote on last edited by
        #3

        great, i fixed it, thanks man.

        Solitary wolf

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved