LPS-39542 Inefficient password generation logic and potential stack over...

...flow caused by the recursive call