Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Suggest a fast way to do?

Suggest a fast way to do?

Scheduled Pinned Locked Moved C / C++ / MFC
question
30 Posts 11 Posters 0 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.
  • J john5632

    I have a CRC code for particuler string. I need to get the string corssspoding to CRC. My mean to say I need to generate all possible combination of string from lenght 1 to n untill I get the desired CRC value. I know, string may be different from original one. How can I acoomplish this in a fast way?

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    You can't, CRC is one way only: see here[^].

    Unrequited desire is character building. OriginalGriff

    J 1 Reply Last reply
    0
    • L Lost User

      You can't, CRC is one way only: see here[^].

      Unrequited desire is character building. OriginalGriff

      J Offline
      J Offline
      john5632
      wrote on last edited by
      #3

      I am getting the desired string which generate given CRC but it slow because I am generating string from length 1 to n. Is there a way to make it faster? Or Can I get the string legnth from CRC?

      L 1 Reply Last reply
      0
      • J john5632

        I am getting the desired string which generate given CRC but it slow because I am generating string from length 1 to n. Is there a way to make it faster? Or Can I get the string legnth from CRC?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        john5632 wrote:

        Is there a way to make it faster?

        It's unlikely, given that you have to try every possible combination.

        john5632 wrote:

        Can I get the string legnth from CRC?

        No, it's a one-way value.

        Unrequited desire is character building. OriginalGriff

        J 1 Reply Last reply
        0
        • L Lost User

          john5632 wrote:

          Is there a way to make it faster?

          It's unlikely, given that you have to try every possible combination.

          john5632 wrote:

          Can I get the string legnth from CRC?

          No, it's a one-way value.

          Unrequited desire is character building. OriginalGriff

          J Offline
          J Offline
          john5632
          wrote on last edited by
          #5

          But I read somwhat like this somewhere that do some opeartion with calculated CRC untill we get zero? Is there something like this?

          L enhzflepE 2 Replies Last reply
          0
          • J john5632

            I have a CRC code for particuler string. I need to get the string corssspoding to CRC. My mean to say I need to generate all possible combination of string from lenght 1 to n untill I get the desired CRC value. I know, string may be different from original one. How can I acoomplish this in a fast way?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            Do you know what CRCs are for? They are for checking the validity of the data, to make sure it hasnt got corrupted. It is not a representation of the data, it is merely a numerical sum of the data. Therefore you cannot reconstruct the data from the CRC. If you wanted to know all the strings that could create a particular check sum you would have to run through all the permutations and calculate the sum.

            ============================== Nothing to say.

            J 1 Reply Last reply
            0
            • J john5632

              But I read somwhat like this somewhere that do some opeartion with calculated CRC untill we get zero? Is there something like this?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              john5632 wrote:

              But I read somwhat like this somewhere

              Well I guess you need to use Google to find the reference again.

              Unrequited desire is character building. OriginalGriff

              1 Reply Last reply
              0
              • L Lost User

                Do you know what CRCs are for? They are for checking the validity of the data, to make sure it hasnt got corrupted. It is not a representation of the data, it is merely a numerical sum of the data. Therefore you cannot reconstruct the data from the CRC. If you wanted to know all the strings that could create a particular check sum you would have to run through all the permutations and calculate the sum.

                ============================== Nothing to say.

                J Offline
                J Offline
                john5632
                wrote on last edited by
                #8

                I know I can not construct data from CRC, my aim is to get the string which generate the same CRC value

                E D L 4 Replies Last reply
                0
                • J john5632

                  I have a CRC code for particuler string. I need to get the string corssspoding to CRC. My mean to say I need to generate all possible combination of string from lenght 1 to n untill I get the desired CRC value. I know, string may be different from original one. How can I acoomplish this in a fast way?

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #9

                  What kind of CRC you are dealing with?

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  J 1 Reply Last reply
                  0
                  • C CPallini

                    What kind of CRC you are dealing with?

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    J Offline
                    J Offline
                    john5632
                    wrote on last edited by
                    #10

                    CRC32

                    A G 2 Replies Last reply
                    0
                    • J john5632

                      I know I can not construct data from CRC, my aim is to get the string which generate the same CRC value

                      E Offline
                      E Offline
                      Emilio Garavaglia
                      wrote on last edited by
                      #11

                      I don't know if it is just a typo but ... your aim is impossible to get. There are infinite strings that can give the same CRC. So first start to think as "plural", then ... the only way is "try/retry/retry ...." until you retain to have enough of them.

                      2 bugs found. > recompile ... 65534 bugs found. :doh:

                      1 Reply Last reply
                      0
                      • J john5632

                        CRC32

                        A Offline
                        A Offline
                        App_
                        wrote on last edited by
                        #12

                        crc32 here and here

                        1 Reply Last reply
                        0
                        • J john5632

                          CRC32

                          G Offline
                          G Offline
                          Goto_Label_
                          wrote on last edited by
                          #13

                          this crc32 ?

                          1 Reply Last reply
                          0
                          • J john5632

                            I have a CRC code for particuler string. I need to get the string corssspoding to CRC. My mean to say I need to generate all possible combination of string from lenght 1 to n untill I get the desired CRC value. I know, string may be different from original one. How can I acoomplish this in a fast way?

                            S Offline
                            S Offline
                            Software_Developer
                            wrote on last edited by
                            #14

                            Lookup tables are fast.

                            J 1 Reply Last reply
                            0
                            • S Software_Developer

                              Lookup tables are fast.

                              J Offline
                              J Offline
                              john5632
                              wrote on last edited by
                              #15

                              how table will be fast?

                              S 1 Reply Last reply
                              0
                              • J john5632

                                I know I can not construct data from CRC, my aim is to get the string which generate the same CRC value

                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #16

                                john5632 wrote:

                                ...my aim is to get the string which generate the same CRC value

                                So are you wanting help with permutations or creating a CRC? Those are two unrelated tasks.

                                "One man's wage rise is another man's price increase." - Harold Wilson

                                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                J 1 Reply Last reply
                                0
                                • D David Crow

                                  john5632 wrote:

                                  ...my aim is to get the string which generate the same CRC value

                                  So are you wanting help with permutations or creating a CRC? Those are two unrelated tasks.

                                  "One man's wage rise is another man's price increase." - Harold Wilson

                                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                  J Offline
                                  J Offline
                                  john5632
                                  wrote on last edited by
                                  #17

                                  yes

                                  D 1 Reply Last reply
                                  0
                                  • J john5632

                                    yes

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #18

                                    So then why not focus on a much smaller problem? Trying to build the space shuttle in one setting will never work. You need to build it in pieces. When each of those smaller pieces are working, your overall problem will be solved.

                                    "One man's wage rise is another man's price increase." - Harold Wilson

                                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                                    1 Reply Last reply
                                    0
                                    • J john5632

                                      I have a CRC code for particuler string. I need to get the string corssspoding to CRC. My mean to say I need to generate all possible combination of string from lenght 1 to n untill I get the desired CRC value. I know, string may be different from original one. How can I acoomplish this in a fast way?

                                      C Offline
                                      C Offline
                                      Chuck OToole
                                      wrote on last edited by
                                      #19

                                      I have read through this chain (I was going to say 'string' but that would only confuse the issue) You have to understand folks here, many are just as curious about the 'why' as about the 'how'. You haven't answered 'why are you doing this?' To many, myself included, you have embarked on a totally useless exercise. Why in the world would you want a random string of characters that happens to generate the same CRC32 that you already have in your hand? You cannot possible reconstruct the original string so of what interest is a random string with the same CRC32. Unless you are trying to fool some other program who knows the CRC32 of the data it wants and you are trying to pump some junk at it for some amusing or nefarious reason. So, tell us 'why' you need such a string, you may find some folks who find the problem more interesting than it seems so far.

                                      C 1 Reply Last reply
                                      0
                                      • C Chuck OToole

                                        I have read through this chain (I was going to say 'string' but that would only confuse the issue) You have to understand folks here, many are just as curious about the 'why' as about the 'how'. You haven't answered 'why are you doing this?' To many, myself included, you have embarked on a totally useless exercise. Why in the world would you want a random string of characters that happens to generate the same CRC32 that you already have in your hand? You cannot possible reconstruct the original string so of what interest is a random string with the same CRC32. Unless you are trying to fool some other program who knows the CRC32 of the data it wants and you are trying to pump some junk at it for some amusing or nefarious reason. So, tell us 'why' you need such a string, you may find some folks who find the problem more interesting than it seems so far.

                                        C Offline
                                        C Offline
                                        Chris Losinger
                                        wrote on last edited by
                                        #20

                                        Chuck O'Toole wrote:

                                        Unless you are trying to fool some other program who knows the CRC32 of the data it wants and you are trying to pump some junk at it for some amusing or nefarious reason.

                                        seems likely, to me.

                                        image processing toolkits | batch image processing

                                        1 Reply Last reply
                                        0
                                        • J john5632

                                          how table will be fast?

                                          S Offline
                                          S Offline
                                          Software_Developer
                                          wrote on last edited by
                                          #21

                                          http://en.wikipedia.org/wiki/Lookup_table says: A Lookup table is a data structure, usually an array or associative array, often used to replace a runtime computation with a simpler array indexing operation. The savings in terms of processing time can be significant, since retrieving a value from memory is often faster than undergoing an 'expensive' computation or calculation operation. For example this is regularly done as part of CRC calculations.

                                          #include <iostream.h>

                                          // The CRC lookup table size is 8x32=256
                                          const static unsigned int table[] =
                                          {
                                          0x000000000, 0x077073096, 0x0EE0E612C, 0x0990951BA, 0x0076DC419, 0x0706AF48F, 0x0E963A535, 0x09E6495A3,
                                          0x00EDB8832, 0x079DCB8A4, 0x0E0D5E91E, 0x097D2D988, 0x009B64C2B, 0x07EB17CBD, 0x0E7B82D07, 0x090BF1D91,
                                          0x01DB71064, 0x06AB020F2, 0x0F3B97148, 0x084BE41DE, 0x01ADAD47D, 0x06DDDE4EB, 0x0F4D4B551, 0x083D385C7,
                                          0x0136C9856, 0x0646BA8C0, 0x0FD62F97A, 0x08A65C9EC, 0x014015C4F, 0x063066CD9, 0x0FA0F3D63, 0x08D080DF5,
                                          0x03B6E20C8, 0x04C69105E, 0x0D56041E4, 0x0A2677172, 0x03C03E4D1, 0x04B04D447, 0x0D20D85FD, 0x0A50AB56B,
                                          0x035B5A8FA, 0x042B2986C, 0x0DBBBC9D6, 0x0ACBCF940, 0x032D86CE3, 0x045DF5C75, 0x0DCD60DCF, 0x0ABD13D59,
                                          0x026D930AC, 0x051DE003A, 0x0C8D75180, 0x0BFD06116, 0x021B4F4B5, 0x056B3C423, 0x0CFBA9599, 0x0B8BDA50F,
                                          0x02802B89E, 0x05F058808, 0x0C60CD9B2, 0x0B10BE924, 0x02F6F7C87, 0x058684C11, 0x0C1611DAB, 0x0B6662D3D,
                                          0x076DC4190, 0x001DB7106, 0x098D220BC, 0x0EFD5102A, 0x071B18589, 0x006B6B51F, 0x09FBFE4A5, 0x0E8B8D433,
                                          0x07807C9A2, 0x00F00F934, 0x09609A88E, 0x0E10E9818, 0x07F6A0DBB, 0x0086D3D2D, 0x091646C97, 0x0E6635C01,
                                          0x06B6B51F4, 0x01C6C6162, 0x0856530D8, 0x0F262004E, 0x06C0695ED, 0x01B01A57B, 0x08208F4C1, 0x0F50FC457,
                                          0x065B0D9C6, 0x012B7E950, 0x08BBEB8EA, 0x0FCB9887C, 0x062DD1DDF, 0x015DA2D49, 0x08CD37CF3, 0x0FBD44C65,
                                          0x04DB26158, 0x03AB551CE, 0x0A3BC0074, 0x0D4BB30E2, 0x04ADFA541, 0x03DD895D7, 0x0A4D1C46D, 0x0D3D6F4FB,
                                          0x04369E96A, 0x0346ED9FC, 0x0AD678846, 0x0DA60B8D0, 0x044042D73, 0x033031DE5, 0x0AA0A4C5F, 0x0DD0D7CC9,
                                          0x05005713C, 0x0270241AA, 0x0BE0B1010, 0x0C90C2086, 0x05768B525, 0x0206F85B3, 0x0B966D409, 0x0CE61E49F,
                                          0x05EDEF90E, 0x029D9C998, 0x0B0D09822, 0x0C7D7A8B4, 0x059B33D17, 0x02EB40D81, 0x0B7BD5C3B, 0x0C0BA6CAD,
                                          0x0EDB88320, 0x09ABFB3B6, 0x003B6E20C, 0x074B1D29A, 0x0EAD54739, 0x09DD277AF, 0x004DB2615, 0x073DC1683,
                                          0x0E3630B12, 0x094643B84, 0x00D6D6A3E, 0x07A

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups