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. string combination

string combination

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmsquestion
15 Posts 6 Posters 1 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 Offline
    J Offline
    john5632
    wrote on last edited by
    #1

    Hi, Can you suggest the fastest algorithm to generate unique combination of string of fixed length?

    N 1 Reply Last reply
    0
    • J john5632

      Hi, Can you suggest the fastest algorithm to generate unique combination of string of fixed length?

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      Unique compared to what? Are you talking about a function that will return a new string every time it's called? Or do you have a list of strings you don't want to duplicate?

      J V 2 Replies Last reply
      0
      • N Niklas L

        Unique compared to what? Are you talking about a function that will return a new string every time it's called? Or do you have a list of strings you don't want to duplicate?

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

        yes

        B N 2 Replies Last reply
        0
        • J john5632

          yes

          B Offline
          B Offline
          barneyman
          wrote on last edited by
          #4

          UuidCreate() will create you a unique GUID which you can turn into a 36 character string http://msdn.microsoft.com/en-us/library/aa379205(v=VS.85).aspx[^]

          J 1 Reply Last reply
          0
          • J john5632

            yes

            N Offline
            N Offline
            Niklas L
            wrote on last edited by
            #5

            The fastest way would be to enumerate the possible combinations of the desired alphabet on the fly, and for each call advance a step, and remember the last unique string. For short strings, you could benefit from having them pre-generated.

            1 Reply Last reply
            0
            • N Niklas L

              Unique compared to what? Are you talking about a function that will return a new string every time it's called? Or do you have a list of strings you don't want to duplicate?

              V Offline
              V Offline
              varunpandeyengg
              wrote on last edited by
              #6

              The fastest way what I think will be using TimeStamp. 1) Get the current Time (in Milliseconds ) 2) Append it to string or if comfortable, use the same as a string... UuidCreate() is a good option but fastest will be timestamp + YourSignature -- CHEERS!!!

              CPalliniC 1 Reply Last reply
              0
              • B barneyman

                UuidCreate() will create you a unique GUID which you can turn into a 36 character string http://msdn.microsoft.com/en-us/library/aa379205(v=VS.85).aspx[^]

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

                Thanks for your reply. But I want the all possible comabination of given string of specific length. I am developing a password recovery utiluty so I need to pass all string combination to match the desired string. Can you suggest me the fastest one to do so.

                N 1 Reply Last reply
                0
                • V varunpandeyengg

                  The fastest way what I think will be using TimeStamp. 1) Get the current Time (in Milliseconds ) 2) Append it to string or if comfortable, use the same as a string... UuidCreate() is a good option but fastest will be timestamp + YourSignature -- CHEERS!!!

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  You mean the fastest in 'code development time', I guess.

                  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]

                  In testa che avete, signor di Ceprano?

                  J 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    You mean the fastest in 'code development time', I guess.

                    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
                    #9

                    Almost all utilty find the password string match within few seconds. I want to do the same. So I need to pass string to match. So suggest me fastest method to generate string. Please suggest something meaningful.

                    CPalliniC C 2 Replies Last reply
                    0
                    • J john5632

                      Almost all utilty find the password string match within few seconds. I want to do the same. So I need to pass string to match. So suggest me fastest method to generate string. Please suggest something meaningful.

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #10

                      That's not your original request (at least in the motivation). Why should we encourage your hacking intentions?

                      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]

                      In testa che avete, signor di Ceprano?

                      V 1 Reply Last reply
                      0
                      • J john5632

                        Thanks for your reply. But I want the all possible comabination of given string of specific length. I am developing a password recovery utiluty so I need to pass all string combination to match the desired string. Can you suggest me the fastest one to do so.

                        N Offline
                        N Offline
                        Niklas L
                        wrote on last edited by
                        #11

                        Check my post about enumerating the strings. But before you get too enthusiastic, you should read about something that might get in your way: Salt[^].

                        1 Reply Last reply
                        0
                        • CPalliniC CPallini

                          That's not your original request (at least in the motivation). Why should we encourage your hacking intentions?

                          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]

                          V Offline
                          V Offline
                          varunpandeyengg
                          wrote on last edited by
                          #12

                          You are right... I think the intension is a bit shabby... ha ha ha ha. Caught!!! This guy needs to enumerate all possible string. Brute Force with Alpha Numerics takes a lot of time + Ethics please.

                          J 1 Reply Last reply
                          0
                          • V varunpandeyengg

                            You are right... I think the intension is a bit shabby... ha ha ha ha. Caught!!! This guy needs to enumerate all possible string. Brute Force with Alpha Numerics takes a lot of time + Ethics please.

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

                            If you can not give answer dont laungh on others :)

                            V 1 Reply Last reply
                            0
                            • J john5632

                              Almost all utilty find the password string match within few seconds. I want to do the same. So I need to pass string to match. So suggest me fastest method to generate string. Please suggest something meaningful.

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

                              the trick to doing it quickly is to not generate all possible strings. the trick is to generate likely strings first. "dictionary" is the magic word. if the dictionary fails, then you have to do it the hard way: aaaa aaab aaac aaad ... ZZZZ

                              image processing toolkits | batch image processing

                              1 Reply Last reply
                              0
                              • J john5632

                                If you can not give answer dont laungh on others :)

                                V Offline
                                V Offline
                                varunpandeyengg
                                wrote on last edited by
                                #15

                                Hey John... Always try to be smart while seeking answers of indirect questions. :cool: You have been already answered :|. BTW In Advance Login system (used in most of the places where you see "User Name" and "Password" currently), the no. of guesses you can make is always limited. So Brute force really shouldn't be your approach. The Probability of you cracking the password is 1/((All the case sensitive alphabet + Numbers + Special Characters) ^ (length of the password - which is unknown). If you are still trying - Read this: - This guess will be +ve if you get the correct password in "almost The Best case" i.e. you must be able to guess it in 3 chances (approx). (Advice) Try something else... Best Super Computers if used will take days to crack one strong password by Brute Force. And yes, Always be ethical!!! PS: - The above message has no relevance to the initial question.

                                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