blob: 2f39d6799f5a67c12ee6c2f31bb28d84f4471669 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Linq;
namespace IOL.Helpers;
public static class RandomString
{
private static readonly Random _random = new();
public static string Generate(int length, bool numeric = false) {
var chars = numeric switch {
false => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
true => "0123456789"
};
return new string(Enumerable.Repeat(chars, length).Select(s => s[_random.Next(s.Length)]).ToArray());
}
}
|