Logic for repeating characters and guaranteeing certain characters are generated to increase security