libzc: refactor pwgen_generate function, should be a bit faster