### What is the secret to becoming the greatest programmer in the whole wide world?

Pages: 123456
Again, your problem is "The program cannot crack the string", right?
 ``12345678910111213141516`` ``````bool crackpair (string &pair, string &crack, bool &pass) { for (int a = 0; a<45 ; a++) for (int b = 0; b<45 ; b++) for (int c = 0; c<45 ; c++) for (int d = 0;d<45;d++ ){ string temppair = singles[a]+singles[b]+singles[c]+singles[d]; cout << temppair; if (pair == temppair) { crack = temppair; return pass = false; system ("cls"); break; } } }``````

This is equivalent to the way you had it. But I don't think it does what you think it does.

 ``` slctr = 1+(rand()%44); slctr2 = 1+(rand()%44);```

Your getting a number from between 1 and 44 with this. What about 0?
Last edited on
Get rid of 1. Replace '44' with '45'
Last edited on
actually my head was still in pairs itssimple but dumb and expected of tired mind; i got four numbers and four four loops...i need eight!!

oh yeah and thats obvious now i see it.

i hate 0...no i just forgot the plus1 was there
Last edited on
You want : eight-character string and use 8 character-loops to crack it?
Or anything else? :/
 ``12345678910111213141516171819`` ``````bool crackpair (string &combo) { for (int a = 0; a<45 ; a++) for (int b = 0; b<45 ; b++) for (int c = 0; c<45 ; c++) for (int d = 0;d<45;d++ ) for (int e = 0; e<45 ; e++) for (int f = 0; f<45 ; f++) for (int g = 0; g<45 ; g++) for (int h = 0;h<45;h++ ) if ( singles[a] + singles[b] +singles[c] + singles[d] +singles[e] + singles[f] +singles[g] + singles[h] == combo ) return true; return false; }``````

Your problem may be that it might take you a while to do over 16 trillion loops.
Last edited on
there she is working like she is supposed too...
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119`` ``````#include #include #include #include #include #include using namespace std; string pair1,pair2,pair3,pair4,total,dash,crack1; bool pairone = true; string singles[45] = {"1","2","3","4","5","6","7","8","9","0", "q","w","e","r","t","y","u","i","o", "p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m", "!","£","\$","%","^","&","*","(",")"}; string getrandpair () { string pair,p1,p2; int slctr,slctr2; slctr = 1+(rand()%44); slctr2 = 1+(rand()%44); p1 = singles [slctr]; p2 = singles [slctr2]; return pair = p1+p2; } bool crackpair (string &pair, string &crack, bool &pass) { string temppair; for (int a = 0; a<45 ; a++) for (int b = 0; b<45 ; b++) for (int c = 0; c<45 ; c++) for (int d = 0;d<45;d++ ) for (int e = 0; e<45; e++) for (int f = 0; f<45;f++) for (int g = 0; g<45;g++) for (int h = 0; h<45;h++) { temppair =singles[a]+ singles[b]+singles[c]+singles[d]+singles[e]+singles[f]+singles[g]+singles[h]; cout << temppair; if (pair == temppair) { crack = temppair; return pass =false; system ("cls"); break; } } } int main () { system ("color a"); srand(time(0)); dash = "-"; int refresh; bool quit = true, restart = true; while (quit != false) { cout << "type 1 to create new code or type 2 to quit "<> refresh; switch (refresh) { case 2: quit = false; break; case 1: while (restart != false) { pair1 = getrandpair(); pair2 = getrandpair(); pair3 = getrandpair(); pair4 = getrandpair(); cout << pair1<> refresh; switch (refresh) { case 2: restart = false; break; case 1: while (restart != false) { while (pairone != false) { crackpair(pair1,crack1,pairone); } restart = false; } break; } restart = true; break; cout << "the code was; "<< crack1<<"restart? y/n"<

spoonlicker wishes he was me.
@iseeplusplus; yeah thats why we want concurence right? or like i did and just split it up into pairs... but i wasnt allowed to do that

its 458!

5mins and still 111999!
Last edited on
Infinite program loop (° °) Now, example?
 ``1234`` `````` while (pairone != false) { crackpair(pair1,crack1,pairone); }``````

How many characters are there in pair1?

 5mins and still 111999!

It won't be possible while printing out every guess. You may also like to reduce the number of symbols in your set.
Last edited on
just two, oh wait now lol 4 pairs! or 8 digits!!, its called pair1 from the last code where i paired em up to save time and then i butchered it to make this code. i meant 5 mins and still 11199999!! now today i suss out threading :)
do i install c++11?
need boost i downloaded it but dont know how to link it, besides the tutorials are way complicated
Last edited on
http://nuwen.net/mingw.html

Command line, you'll find instructions text file after you install it. Contains Boost.
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148`` ``````#include #include #include #include #include #include using namespace std; vector spair;//Edited string dash = "-", crack2; long tstart, tend; //Clock variables string singles[45] = {"1","2","3","4","5","6","7","8","9","0", "q","w","e","r","t","y","u","i","o", "p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m", "!","£","\$","%","^","&","*","(",")"}; char chrSingles[45] = {'1','2','3','4','5','6','7','8','9','0', 'q','w','e','r','t','y','u','i','o', 'p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m', '!','£','\$','%','^','&','*','(',')'}; string getrandpair (unsigned int nlength){ string st;st.erase(); if(!nlength)nlength++; for(int i = 0;i < nlength;i++)st += singles[rand() % 45]; return st; } bool crackpair (string &stpair, string &crack, int nlen){if(!nlen)return false; int *digit = new int[nlen]; string stemp;stemp.erase(); for(int i =0;i < nlen;i++)digit[i] = -1; //Because : (++) code first bool exit = false; int nLevel; int nchrCount = 0; //Number of (stemp) characters stemp += singles[0]; //Allocates a character first tstart = clock(); //Clock starts while(stpair != stemp){ digit[0]++;stemp[0] = chrSingles[digit[0]]; if(digit[0] == 45){ digit[0] = -1;nLevel = 1; //Resets value, switch to the next digit level if(!nchrCount){nchrCount = 2;stemp += singles[0];} //Exception : Allocates the second character Counting: digit[nLevel]++;stemp[nLevel] = chrSingles[digit[nLevel]]; if(digit[nLevel] == 45){ digit[nLevel] = -1;nLevel++; //Next level if(nLevel >= nchrCount){nchrCount++;stemp+=singles[0];} // Allocates a character if needed goto Counting;}} cout << stemp; //Prints the current value } tend = clock(); //End clock crack = stemp; //Result delete digit; //Free memory return true; //Always } int main (){srand(time(0)); int refresh = 0, npair = 0, nlen = 0; bool quit = false, restart = true; while (1){ npair = nlen = 0; while(refresh != 1 && refresh != 2){ cout << "Type 1 to create new code or type 2 to quit : "; cin >> refresh;} cout << endl; if(refresh == 2)break; //Quit while(!npair){ cout << "How many string units : "; cin >> npair;} cout << endl; /////////////////////////////////////////////////////////////////////////////// spair.clear();for(int i = 0;i < npair;i++)spair.push_back(crack2); //////////////////////////////////////////////////////////////////////////////// while(!nlen){ cout << "Length of each string : "; cin >> nlen;} //////////////////////////////////////////////////////////////////////////////////////////////////////////// switch (refresh) { case 2: quit = true;break; case 1: for(int i = 0;i < npair;i++){ spair[i] = getrandpair(nlen); //Get... cout << spair[i]; if(i != npair - 1)cout << dash;} cout << endl << endl; //Next line for(int a = 0;a < npair;a++){ //Start : cout << spair[a]; refresh = 0; while(refresh != 1 && refresh != 2){ cout << ": Press 1 to begin decoding and 2 to quit"<< endl; cin >> refresh;} switch (refresh) { case 2: refresh = 0;cout << endl;goto Quit;break; case 1 : crackpair(spair[a], crack2, nlen); cout << endl << endl << "Result : " << crack2 << endl; cout << "Time : " << (tend - tstart) / 1000.0f << endl << endl; break; } } Quit : nlen = nlen; //Crazy random code... :P } //////////////////////////////////////////////////////////////////////////////////////////////////////////// } return 0; }``````

Edit : Changed a bit...

Enjoy... :) :D ^.^ :D
Last edited on
Is this right?

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374`` ``````#include #include #include #include #include static const std::vector __charset = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '@', '#', '\$', '%', '^', '&', '*', '?', '<', '>', '~' }; template static T random(T min = std::numeric_limits::min(), T max = std::numeric_limits::max()) { static int seeded; if (!(seeded)) { srand((unsigned)time(0)); seeded = 1; } return min + T(((max - min) * rand()) / (RAND_MAX + 1.0)); } static char random_char() { return __charset[random(0, __charset.size())]; } static std::pair random_pair() { return { random_char(), random_char() }; } static std::vector < std::pair > random_pairs() { return { random_pair(), random_pair(), random_pair(), random_pair() }; } static void guess_pair(std::pair pair) { for (char c : __charset) { if (c == pair.first) { for (char d : __charset) { if (d == pair.second) std::cout << c << d; } } } } static void guess(std::vector < std::pair >& pairs) { guess_pair(pairs[0]); std::cout << '-'; guess_pair(pairs[1]); std::cout << '-'; guess_pair(pairs[2]); std::cout << '-'; guess_pair(pairs[3]); std::cout << std::endl; } int main() { std::vector < std::pair > pairs = random_pairs(); std::cout << pairs[0].first << pairs[0].second << '-' << pairs[1].first << pairs[1].second << '-' << pairs[2].first << pairs[2].second << '-' << pairs[3].first << pairs[3].second << std::endl; clock_t start = clock(); guess(pairs); std::cout << "Solved in " << clock() - start << " ms." << std::endl; return 0; }``````
Last edited on
ahh, so i could of made a function to search each of the digits all at the same time by having the function called through a loop, is that threading??
I was thinking guess the whole combination at once; get feedback wether the whole combination is correct. How often can you crack a password 2 entries at a time?
what do you mean?
i guess checking each digit is correct or not is similar to what i did in pairs, i could have got a loop to do the all at once i guess
I have an example above.
Look at the example. And now...zzz :)

Have you tested it?
Last edited on
Unfortunately MinGW 4.7.2 doesn't implement std::thread.

Damn it's ugly.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145`` ``````#include #include #include #include #include #include #include #include #include #include #include #include namespace { const std::vector availableElements { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '@', '#', '\$', '%', '^', '&', '*', '?', '<', '>', '~' }; const std::vector::size_type defaultCombinationSize = 8; std::vector elusiveCombination; } // namespace namespace src { std::vector createRandomCombination(std::vector::size_type vcs = ::defaultCombinationSize) { std::default_random_engine dre(std::chrono::system_clock::now().time_since_epoch().count()); std::uniform_int_distribution::size_type> uid(0, ::availableElements.size() - 1); auto getRandomIndex = std::bind(uid, dre); std::vector vc(vcs); std::generate(vc.begin(), vc.end(), [&getRandomIndex]() -> char { return ::availableElements.at(getRandomIndex()); }); return vc; } std::ostream & operator << (std::ostream &os, const std::vector &vc) { for (char c: vc) os << c; return os; } std::pair, bool> first(std::vector vc) { if (vc.size() == ::defaultCombinationSize) return std::make_pair(std::vector{}, false); vc.push_back(::availableElements.front()); return std::make_pair(vc, true); } std::pair, bool> next(std::vector vc) { if (vc.back() == ::availableElements.back()) return std::make_pair(std::vector{}, false); vc.back() = *++std::find(::availableElements.begin(), ::availableElements.end(), vc.back()); return std::make_pair(vc, true); } void whinyChecker(const std::vector &candidateCombination, std::ostream &os = std::cout) { if (candidateCombination.size() != ::elusiveCombination.size()) throw std::length_error("candidateCombination and ::elusiveCombination are not the same size."); else if (std::equal(candidateCombination.begin(), candidateCombination.end(), ::elusiveCombination.begin())) { os << ::elusiveCombination << " == " << candidateCombination << std::endl; throw std::logic_error("Solution was found, so why go on?"); } else os << ::elusiveCombination << " != " << candidateCombination << std::endl; } void whinyBacktrack(const std::vector &target, const std::vector &built) { if (target.size() == built.size()) { whinyChecker(built); return; } auto possibleSolution = first(built); while (possibleSolution.second) { whinyBacktrack(target, possibleSolution.first); possibleSolution = next(possibleSolution.first); } } std::list> generateLimits() { std::list> lvc; for (char c: ::availableElements) { std::vector vc; vc.push_back(c); while (vc.size() < ::defaultCombinationSize) vc.push_back(::availableElements.back()); lvc.push_back(vc); } return lvc; } } // namespace src using src::operator<<; #ifndef GCC_ACTUALLY_IMPLEMENTS_THREADS int main() { ::elusiveCombination = src::createRandomCombination(); src::whinyBacktrack(src::generateLimits().back(), {}); } #else int main() { ::elusiveCombination = src::createRandomCombination(); std::list lt; for (const std::vector &vc: src::generateLimits()) lt.push_back(std::thread(src::whinyBacktrack, std::cref(vc), {})); for (std::thread &t: lt) t.join(); } #endif ``````
Last edited on
Now I think that my example code above is outdated. But, have you tested my code above yet? :)
But, no problem. Only thread-thread feature is missing. I'll add, compile and rebuild the code again, just use the multi-threading at a proper place... And...don't use too much... :)
Expect me!!!
Last edited on
Pages: 123456