fixed error in genPassword function where string index would occasionally be out of range