password generating logic