Mostly Conceptual Answer
If you are trying to randomize the string, recognize then that putting a logical filter that letters can not repeat actually lowers entropy, and thus security or base randomness for any purpose. Also, this will be very difficult as it would require re-scrambling if a repeat is detected.
Take for instance:
randomize "add" - characters as 123
a - 1
ad - 13
add - 132
! back to drawing block
As a human we know that only one non-repeating string can come of this, dad (in the character order of 312 and 213), but the system will hit every option until it hits one of those, starting over each time...
add > add > dad > dad > dda > dda
123 > 132 > 213 > 312 > 321 > 231
Or a word like sorry
:
There are 120 permutations, of those, there are 8 different ways in which 3rd and 4th letters repeat (rr
) in either 34
, or 43
fashion (2 ways, and four positions in the resulting string). Of the 120 possibilities, this accounts for 48 permutations, and many of those permutations are not discovered until many characters in.
In words with more repeating characters (like, for instance comodo
, with 6 different doubles of o
, this covers 576 permutations of the possible 720) you get into conditions where your script becomes woefully inefficient due to thrashing...
But, if you need this, your best bet would be to write a function that randomizes a word, checks, then randomizes again. Doing it by hand (one character at a time) will be slower for easier words, and you will have about as much luck as anything else for troublesome words. Let Lady Luck guide you...