Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. New SimpleCrypt page
Forum Updated to NodeBB v4.3 + New Features

New SimpleCrypt page

Scheduled Pinned Locked Moved Wiki Discussion
98 Posts 26 Posters 89.3k 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.
  • P Offline
    P Offline
    paucoma
    wrote on last edited by
    #19

    Aha, got it all sorted out, thanks

    I had my suspicions on that, but thought that the "<<" and ">>" operators may use seperate index variables.

    Andre: it would be great if you could incorporate in the Example usage code the following so it works out of the box.

    @
    buffer.open(QIODevice::WriteOnly);
    buffer.close();
    buffer.open(QIODevice::ReadOnly);
    @

    Because newbies like myself:

    • copy + paste + compile
      ** if it works -> adapt to needs
      ** if it doesn't -> get lost in the simplest things

    Although I must admit that I am learning loads of things through all these problems I get myself into.

    Gerolf: Once again thanks for your quick and effective response.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #20

      paucoma, thank you for your comments and suggestions. I have changed the wiki page accordingly. I am glad you solved the problem, and that it turned out the class itself was not at fault ;-)

      I must admit that I wrote the examples directly in the wiki page, and thats when errors like these happen. Sorry about that! I hope the current version is more managable? Note that I was talking about "at the other end", implying that the decryption code was not meant to be used in the same function (and thus, implicitly, with the same buffer).

      1 Reply Last reply
      0
      • P Offline
        P Offline
        paucoma
        wrote on last edited by
        #21

        Thanks Andre for making the modifications.

        I have corrected myself a few other details I found.

        P.S. I didn't know that I had such a priviledge.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #22

          Thanks for your effort, I really appreciate it. If you want, you're welcome to update it yourself in the wiki article :-)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #23

            Hi Andre,

            one suggestion to the wiki page:
            In the section SimpleCrypt in use it would be nice to have a list of the encryp/decrypt functions. You state thete are two times 4, but not the names :-)
            this means searching inside the code :-)

            The rest sound really god. Thanks for the article.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #24

              [quote author="Gerolf" date="1300958192"]Hi Andre,

              one suggestion to the wiki page:
              In the section SimpleCrypt in use it would be nice to have a list of the encryp/decrypt functions. You state thete are two times 4, but not the names :-)
              this means searching inside the code :-)

              The rest sound really god. Thanks for the article.[/quote]

              Fair enough, done. :-)

              Thanks for the praise.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #25

                Hi Andre,

                I'm currently reading your second article, and found the following "here":http://developer.qt.nokia.com/wiki/SimpleCrypt_algorithm_details#00f4e5788aab6d3546bb433842dbbefc :

                bq. The payload data block’s contents are encrypted with a four byte (quint64) key.

                quint64 is a 64 bit integer, which means 8 byte.

                so also in the snipet page, you say:

                @
                SimpleCrypt crypto(Q_UINT64_C(0x7F29B208)); //some random number
                @

                this is just a 32 bit number, not 64 bit.

                @
                void SimpleCrypt::splitKey()
                {
                m_keyParts.clear();
                m_keyParts.resize(4);
                for (int i=0;i<4;i++) {
                quint64 part = m_key;
                for (int j=i; j>0; j--)
                part = part >> 8;
                part = part & 0xff;
                m_keyParts[i] = static_cast<char>(part);
                }
                }
                @

                this also only uses 4 bytes, not 8.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #26

                  some additional topics:

                  in "Decrypted payload":http://developer.qt.nokia.com/wiki/SimpleCrypt_algorithm_details#2d478ba9ee3cf03e338b506b1a0292dc

                  SH1 and CRC have the same description:

                  bq. In case the Protection Checksum flag has been set, the layout of the decrypted payload looks like this:

                  I think this is just a copy paste error.

                  As I'm through now, no more things :-)
                  Very good article, interesting to read. Thanks.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #27

                    Thank you very much for this catch, Gerolf! You are absolutely right, and this is a big mistake in the algorithm as well. I will take care of fixing this ASAP.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #28

                      OK, fixed on both pages. Very embarrassing, I must say. :(

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #29

                        Now it looks good, thanks :-)

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          luca
                          wrote on last edited by
                          #30

                          I tried today SimpleCrypt class and it was very useful.

                          Thanks!

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #31

                            Glad you like it!

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              cincirin
                              wrote on last edited by
                              #32

                              Hi Andre.
                              First of all, thanks for sharing your code. :-)

                              I was playing with this algorithm, but I noticed a strange situation: sometimes these work well, sometimes not.

                              This is the string which I have tested :
                              10197016915918185882701231384169178913312058269-10750535699546572956586080750006397
                              The key is: 13775729

                              I tested both with string and binary data (there are several integer values).

                              So if I encrypt this string, and then decrypt it, sometimes original string is equal with decrypted string, sometimes differ.

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                andre
                                wrote on last edited by
                                #33

                                You'll have to provide a small testprogram that shows the problem, otherwise I can not help you debug the issue.

                                1 Reply Last reply
                                0
                                • C Offline
                                  C Offline
                                  cincirin
                                  wrote on last edited by
                                  #34

                                  A small test is something like :

                                  @
                                  QString cryptSerialNumber;

                                  void testCrypt()
                                  {
                                  SimpleCrypt processSimpleCrypt(13775729);
                                  QString uniqueString("10197016915918185882701231384169178913312058269-10750535699546572956586080750006397");
                                  cryptSerialNumber = processSimpleCrypt.encryptToString(uniqueString);
                                  }

                                  void testDecrypt()
                                  {
                                  SimpleCrypt processSimpleCrypt(13775729);
                                  QString uniqueString = processSimpleCrypt.decryptToString(cryptSerialNumber);
                                  }
                                  @

                                  Sometimes decrypted "uniqueString" is the same as the original, but sometimes is :
                                  1019701691591818588270123138416917891691033658269-10750535699546572956586080750006397, almost the same with original, but not the same :-)

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    andre
                                    wrote on last edited by
                                    #35

                                    Strange. Very, very strange. In such cases, are the cryptSerialNumber the same, or do they differ as well?

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      cincirin
                                      wrote on last edited by
                                      #36

                                      After encrypt step, I write "cryptSerialNumber" into file.
                                      In decrypt step, I read it from file.

                                      I assume it is the same, the file remain unchanged. I'll do more debug to tell you if "cryptSerialNumber" is the same ...

                                      1 Reply Last reply
                                      0
                                      • C Offline
                                        C Offline
                                        cincirin
                                        wrote on last edited by
                                        #37

                                        Yes, the “cryptSerialNumber” is the same:
                                        AwNgsVZWVlYFfdbw6is6+srGtTZtFxBm1rc5z8/z1lQNfU74jOk+0bsNs2vMFNlbB5RqAZI/dgJEH79ElSotizgvmf0/xg==

                                        Yes, is very strange ...

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          andre
                                          wrote on last edited by
                                          #38

                                          Well, at least, that narrows down the issue to the decrypting routine... Issue is: there is nothing in there that I can think of might be influenced by something else than the input string itself. I will have to investigate, but I can not do that right now. I'll need a few days before I get around to doing that. Sorry. I would like to encourage you to try to debug it on your own as well. At the very least, insert some debug statements at strategic places in the code to see what goes on.

                                          Hmmmm... now that I think about it: it is actually very strange that your encrypted string stays the same. It should be different each time you do the encryption, even on the same input string. That is because a random byte is inserted at the front of the byte array to encrypt (line 115 and 116 from simplecrypt.cpp).

                                          1 Reply Last reply
                                          0

                                          • Login

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