Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a random string
ResourceFunction["RandomString"][n] gives a pseudorandom string of length n using the alphabet of the default language. | |
ResourceFunction["RandomString"][{n1,n2,…,nm}] gives an n1×n2×…nm-1 array of strings each of length nm using the alphabet of the default language. | |
ResourceFunction["RandomString"][{s1,s2,…},n] gives a pseudorandom string of length n using the characters si. | |
ResourceFunction["RandomString"][{w1,w2,…}→{s1,s2,…},n] gives a pseudorandom string of length n using the characters si weighted using wi. | |
ResourceFunction["RandomString"][entity,n] gives a pseudorandom string of length n using the alphabet retrieved from the language or alphabet entity entity. | |
ResourceFunction["RandomString"]["preset",n] gives a pseudorandom string of length n using the character preset "preset". |
| "LowerCase" | lowercase letters of the default alphabet |
| "UpperCase" | uppercase letters of the default alphabet |
| "LowerUpperCase" | lower- and uppercase letters of the default alphabet |
| "Numbers" | use the string representation of the numbers 0-9 |
| "LowerCaseNumbers" | lowercase letters of the default alphabet and numbers |
| "UpperCaseNumbers" | uppercase letters of the default alphabet and numbers |
| "LowerUpperCaseNumbers" | lower- and uppercase letters of the default alphabet and numbers |
Create a random string of length 8:
| In[1]:= |
| Out[1]= |
Create multiple random strings simultaneously:
| In[2]:= |
| Out[2]= |
Randomly choose from a set of characters:
| In[3]:= |
| Out[3]= |
Randomly choose from a set of characters using weights:
| In[4]:= |
| Out[4]= |
Use an alphabet entity:
| In[5]:= |
| Out[5]= |
Use a language entity:
| In[6]:= |
| Out[6]= |
Use a preset of characters:
| In[7]:= |
| Out[7]= |
Generate an array of strings of length 4:
| In[8]:= |
| Out[8]= |
The dimensions of the output are Most[dimensions]:
| In[9]:= |
| Out[9]= |
Arbitrary characters can be used:
| In[10]:= |
| Out[10]= |
Create a random password:
| In[11]:= |
| Out[11]= |
Create a random password excluding commonly mistyped characters (0, o and O, etc.):
| In[12]:= | ![]() |
| Out[12]= |
Create a random bogus sentence:
| In[13]:= | ![]() |
| Out[13]= |
Alphabet or language entities can be given:
| In[14]:= |
| Out[14]= |
| In[15]:= |
| Out[15]= |
Some languages have multicharacter letters in their alphabet, such that the supplied length might differ from the result:
| In[16]:= |
| Out[16]= |
If the input contains multicharacter letters, the length might be different than expected:
| In[17]:= |
| Out[17]= |
RandomString by default uses $Language to determine the alphabet. One can temporarily override it:
| In[18]:= | ![]() |
| Out[18]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License