using System.Text;
|
|
namespace utils
|
{
|
/// <summary>
|
/// 通用函数库
|
/// </summary>
|
public static class utilsFun
|
{
|
private const string ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}|;:',.<>?/`~";
|
|
public static string GenerateRandomString(int length)
|
{
|
StringBuilder builder = new StringBuilder();
|
Random random = new Random();
|
|
for (int i = 0; i < length; i++)
|
{
|
int index = random.Next(ValidChars.Length);
|
char randomChar = ValidChars[index];
|
builder.Append(randomChar);
|
}
|
|
return builder.ToString();
|
}
|
}
|
}
|