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. How to use SimlpeCrypt in qt c++
Forum Updated to NodeBB v4.3 + New Features

How to use SimlpeCrypt in qt c++

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 287 Views
  • 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.
  • T Offline
    T Offline
    TheCeylann
    wrote on last edited by
    #1

    I save my password in a text file. I need to save the string by encrypting it during recording. I think I can solve this with SimpleCrypt, but since I started c++ a few days ago, I couldn't use simplecrypt. Can you teach me how to do this?

    void SecondWindow::on_pushButton_8_clicked()
    {
        QFile file(passLocation + "/test/password.txt");
        QFile tmpFile(passLocation + "/test/passwordtemp.txt");
    
    
         if (!file.open(QIODevice::ReadOnly | QIODevice::Text) || !tmpFile.open(QIODevice::WriteOnly | QIODevice::Text))
             return;
    
         QTextStream  in(&file);
    
         QString line = in.readLine();
         qDebug()<< line;
    
    
         if (line == ui->oldPassBox->text() && ui->confirmPass->text() == ui->newPassBox->text())
         {
    
            
             QTextStream  tmp(&tmpFile);
             tmp << ui->newPassBox->text();
             
             
    
         } else
         { 
             QMessageBox::warning(this, "error","Error" );
             QTextStream  tmp(&tmpFile);
             tmp << line     ;
    
         }
    
    
    
     
         file.close();
         tmpFile.close();
         QFile::remove(passLocation + "/test/password.txt");
         QFile::rename(passLocation + "/test/passwordtemp.txt",  passLocation + "/test/password.txt" );
    
        }
    

    I referenced this link for SimpleCrypt [SımpleCrypt]https://wiki.qt.io/Simple_encryption_with_SimpleCrypt) And examples from this link examples

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your first link contains all the code which is needed for this task.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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