Implement an "unmunger" (second attempt) #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For issue #45, and a complete rewrite of my first attempt a few years ago: #55
Instead of splitting by regex, I'm trying out using a trie here. Going character by character, that lets you identify possible substitutions cleanly in linear time. I think it's also more complete in terms of edge cases (ie. where a substitution key is a substring of another sub key)
Example part of the overall trie:
Performance
In order to exhaust all possible substitutions though you do still have to build all combinations out recursively, so I think you can't escape the exponential runtime there. That's why the hard limit on total number of combinations is important. I've noticed though for very long password lengths, if you just copy paste some of the string substitution keys over and over, there's a slowdown. It can take more than a full second to estimate long passwords on my machine. But I suspect the source of the problem might be that this alg is running for every possible substring of the password on top. I'm not fully familiar with the overall structure and intentions of the project but maybe the generation of substrings and this new alg should be merged into one overall alg rather than multiplying eachother, if that makes sense.