New SimpleCrypt page

Page  
5

April 9, 2012

rich rich
Lab Rat
37 posts

Yes, this is the auto-key variant of vigenere cipher, and is a lot stronger than the basic one.

April 9, 2012

Andre Andre
Robot Herder
6417 posts

Interesting stuff. Perhaps I should try to make a new version (still: keeping it simple!) that is a bit stronger.

April 9, 2012

rich rich
Lab Rat
37 posts

If you do, I’d be tempted to use something like RC4 which while not perfect, is very simple to implement.

May 1, 2012

zester zester
Lab Rat
89 posts

Andre I think you did a great job, at documenting not only usage but also the algorithm. I wish all of Qt’s examples were so well thought out ;)

November 18, 2012

katropine katropine
Lab Rat
2 posts

Great job, easy to use. One question, I tested my app on Debian and Mint and no problem, but on Fedora 17 and Arch
I get “Invalid version or not a cyphertext.”

  1.     QByteArray ba = cypher;
  2.  
  3.     char version = ba.at(0);
  4.     if (version !=3) {  //we only work with version 3
  5.         m_lastError = ErrorUnknownVersion;
  6.         qWarning() << "Invalid version or not a cyphertext.";
  7.         return QByteArray();
  8.     }

November 19, 2012

Andre Andre
Robot Herder
6417 posts

Sorry, no idea. I did not test on these sytems, but I have no clue why it would go wrong on a different linux system. That seems unlikely somehow. Perhaps the data you feed into SimpleCrypt is corrupted somehow?

November 19, 2012

katropine katropine
Lab Rat
2 posts

Yes, sorry something else went wrong on those systems and indeed corrupted the settings string.
My Bad.

SimpleCrypt works perfectly.

December 30, 2012

amanjit amanjit
Lab Rat
5 posts

Hi,

Andre wrote:
I have just added a page [developer.qt.nokia.com] in the Snippets category

Thanks for this class. I am invoking it’s constructor with my predefined key (my secret) and I am wondering why qsrand() is initialized with currentTimeMillis or similar (in the constructor code)? I don’t get the same encryption results on multiple invocations so I used my quint64 key to initialize qsrand (in the constructor), then it works..

  1.    SimpleCrypt c1(Q_UINT64_C(0x0c2ad4a4acb9f023)); //some random number
  2.    SimpleCrypt c2(Q_UINT64_C(0x0c2ad4a4acb9f023)); //some random number
  3.  
  4.    qDebug() << "Crypt1 " << c1.encryptToString(QString("justatest"));
  5.    qDebug() << "Crypt2 " << c2.encryptToString(QString("justatest"));

Output

  1.    Crypt1  "AwLLXV+ZSO+x3Ise1Aw="
  2.    Crypt2  "AwIUgoBGlzBuA1TBC9M="

Just wondering :)

December 30, 2012

Andre Andre
Robot Herder
6417 posts

Why would you want to have the same cypher text when using the same clear text and key? As long as the decrypted plain text from these cypher texts is the same, what is the problem with having different cypher texts? The algorithm uses a randomization of the string on purpose. It makes it much harder to leak part of the key because analysis is much harder this way.

An explanation is in the details page that has more on the idea of using a random number as a leading byte.

You replacing that they way you did partly negates this, and thus makes the cypher weaker by a couple of bits. Note that even with your change, encrypting the same plain text using the same SimpleCrypt instance twice will result in different cypher texts.

December 30, 2012

amanjit amanjit
Lab Rat
5 posts

Hi Andre,

Thanks for answering; I wasn’t looking for reasonably strong encryption – I just wanted to always get the same encrypted string for the same input (private key+string_to_be_encrypted); its just for private use anyway, and non-critical.

I am using QCryptographicHash for that now, it solves my problem

December 30, 2012

Andre Andre
Robot Herder
6417 posts

Eh, no, that class does not solve your problem, if you are indeed looking for encryption rather than hashing. There is a big difference between the two…

December 30, 2012

amanjit amanjit
Lab Rat
5 posts
Andre wrote:
Eh, no, that class does not solve your problem, if you are indeed looking for encryption rather than hashing. There is a big difference between the two…

That’s a chicken and egg problem: I don’t want to elaborate on “my problem” and hence prove that I am fine with hashing because of concerns of privacy. Please understand that and thank you for your help.

February 4, 2013

topocc topocc
Ant Farmer
81 posts

worked in QT 5?

February 4, 2013

topocc topocc
Ant Farmer
81 posts

good thing I changed was this:

  1. //QString cypherString = QString::fromAscii(cypher.toBase64());
  2. QString cypherString = QString::fromUtf8(cypher.toBase64());
  3.  
  4. //QString cypherString = QString::fromAscii(cypher.toBase64());
  5. QString cypherString = QString::fromUtf8(cypher.toBase64());
  6.  
  7. //QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toAscii());
  8. QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toUtf8());
  9.  
  10. //QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toAscii());
  11. QByteArray cyphertextArray = QByteArray::fromBase64(cyphertext.toUtf8());

there will be well done this.

February 14, 2013

Ian Monroe Ian Monroe
Lab Rat
8 posts

I was getting SIGABRT’s when attempting to decrypt an empty string with a Qt with debugging enabled. So I’ve added a little check. Doesn’t seem possible to link to wiki history diffs, but you can see it there.

Page  
5

  ‹‹ New Qt for Embedded Linux Series started      new DocumentWindow wiki page - How to do this on Linux / Mac? ››

You must log in to post a reply. Not a member yet? Register here!