B4J Question Generate strong random string

devmobile

Active Member
Licensed User
Hello
In my project,i need generate random string code about 1 million records
I can generate random code with RandomLibrary in php and it is very powerful library
But do we have library looklike php library in b4j?
 

devmobile

Active Member
Licensed User
B4X:
Sub GenerateRandomString (Length As Int) As String
   Dim su As StringUtils
   Dim bytes(Length) As Byte
   SecureRandom1.GetRandomBytes(bytes)
   Return su.EncodeBase64(bytes).SubString2(0, Length)
End Sub
SecureRandom1 is a SecureRandom global variable (jEncryption or Encryption libraries).
I need make 1 million code with this function
Maybe generate same random string with this function?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I don't get it, what exactly do you want to do?
1- create 1Million different and Randing Strings
or
2- create 1random string a populate 1Million records with it?
 
Upvote 0
Top