Android Question create random string (A-Z, 0-9) length = 9 [solved]

Try This:
Code:
Public Sub GetRandomString(Source As String,Count As Int) As String
    Dim Str As StringBuilder
    Str.Initialize
    For i = 0 To Count -1
        Str.Append(Source.CharAt(Rnd(0,Source.Length)))
    Next
    Return Str.ToString
End Sub

Usage:

Code:
Log(GetRandomString("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",9))
 
Upvote 0
How random do you want? You could also do something like use the Encryption library to produce one or more random numbers with the SecureRandom function. Use one of the message digest functions in the Encryption library to create a digest string, and then select nine characters from it, either using the function above, or simply picking a random start position for a substring.
 
Upvote 0
How random do you want? You could also do something like use the Encryption library to produce one or more random numbers with the SecureRandom function. Use one of the message digest functions in the Encryption library to create a digest string, and then select nine characters from it, either using the function above, or simply picking a random start position for a substring.
thanks for the suggestion but im okay with @stevel05 code , dont want to add more libs in my project :)
 
Upvote 0
Upvote 0
Back
Top