Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- bool nextPermutationStr(std::string& s)
- {
- int sumIndex = 0;
- while (s[sumIndex] == 122)
- {
- ++sumIndex;
- if (sumIndex == s.length())
- return false;
- }
- ++s[sumIndex];
- for (int i = 0; i < sumIndex; ++i)
- s[i] = 97;
- return true;
- }
- int main()
- {
- std::string passwordTarget = "kgpggr";
- std::string passwordStart = "aaaaaa";
- do
- {
- if (passwordStart == passwordTarget)
- std::cout << "Password cracked: " << passwordTarget << std::endl;
- } while (nextPermutationStr(passwordStart));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment