Class RandomStringGenerator
Simple utility class for generating random string
s of any arbitrary size.
Inheritance
Namespace: GlitchedPolygons.Utilities.RandomStringGenerator
Assembly: GlitchedPolygons.Utilities.RandomStringGenerator.dll
Syntax
public static class RandomStringGenerator : object
Methods
| Improve this Doc View SourceGenerateRandomString(Char[], Int32)
Generates a random string
from a specific set of legal characters.
If the passed
size
argument is 0, or if legalChars
is null
or empty, string.Empty
is returned.If
size
is <0, the absolute value of that number will be used.On success, a random
string
is returned.
Declaration
public static string GenerateRandomString(char[] legalChars, int size = 32)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | legalChars | The legal characters to be used for the |
System.Int32 | size | The desired output |
Returns
Type | Description |
---|---|
System.String | If the passed |
GenerateRandomString(Int32)
Generates a random string
using only alpha-numeric characters.
If the passed
size
argument is 0, string.Empty
is returned.If
size
is <0, the absolute value of that number will be used.A random
string
is returned.
Declaration
public static string GenerateRandomString(int size = 32)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | How long should the generated |
Returns
Type | Description |
---|---|
System.String | If the passed |
GenerateRandomString(String, Int32)
Generates a random string
from a specific set of legal characters.
If the passed
size
argument is 0, or if legalChars
is null
or empty, string.Empty
is returned.If
size
is <0, the absolute value of that number will be used.On success, a random
string
is returned.
Declaration
public static string GenerateRandomString(string legalChars, int size = 32)
Parameters
Type | Name | Description |
---|---|---|
System.String | legalChars | The legal chars to be used for the |
System.Int32 | size | The desired output |
Returns
Type | Description |
---|---|
System.String | If the passed |
GetDefaultLegalChars()
Gets the default legal characters for string
generation that is used
when no specific legal char[]
array is passed as an argument to the GenerateRandomString(Int32) method.
Declaration
public static char[] GetDefaultLegalChars()
Returns
Type | Description |
---|---|
System.Char[] | Returns a copy of GlitchedPolygons.Utilities.RandomStringGenerator.RandomStringGenerator.DEFAULT_LEGAL_CHARS. |