title: Qt C++ QString to QByteArray Conversion
body: <p>I have created an encrypt/decrypt program, when encrypting I store the encrypted QByteArray in a text file.</p>
  
  <p>When trying to decrypt I retrieved it and then put it into the decryption method, the problem is that I need a way to convert it to QByteArray <strong>without changing the format</strong>, otherwise it will not decrypt properly. What I mean is if the file gave me an encrypted value of 1234 and I converted that to QByteArray by going <code>1234.toLatin1()</code> it changes the value and the decryption does not work. Any suggestions?</p>
  
  <p>My Code:</p>
  
  <pre><code>QFile file(filename);
      QString encrypted;
      QString content;
  
      if (file.open(QIODevice::ReadOnly)) {
          QTextStream stream( &amp;file );
          content = stream.readAll();
      }
  
      encrypted = content.replace("\n", "");
  
      qDebug() &lt;&lt; encrypted; // Returns correct encrypted value
  
      QByteArray a;
      a += encrypted;
  
      qDebug() &lt;&lt; "2 " + a; // Returns different value than previous qDebug()
  
      QByteArray decrypted = crypto.Decrypt(a, key);
      return decrypted;
  </code></pre>