is their a way to do this to text? EX : 1p2a;s\s4w/o4r=dg
It spells out password
Printable View
is their a way to do this to text? EX : 1p2a;s\s4w/o4r=dg
It spells out password
Sure, just define a list of characters that you want to be able to follow the character from your main string and insert a random one:
Code:Dim s As String = "password"
Dim sb As New StringBuilder
Dim r As New Random
' list of valid characters to use after each character
Dim alphabet As String = "1234567890/;'[]\-+|"":?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()"
For Each c As Char In s
sb.Append(c)
sb.Append(alphabet.Substring(r.Next(0, alphabet.Length), 1))
Next
MessageBox.Show(sb.ToString())
When you're talking about anything random your pretty much talking about using a Random object to generate a random number and then using that number appropriately for the app, e.g. to convert to a Char.
In your case you can loop through the characters in a String and alternately add a random Char to a StringBuilder and then a Char from the String. At the end you'll have a string like you want.
Note that you can loop through the characters in a String using a For or For Each loop as though it was an array.