blob: 0d691db496d54a52362543691b1e1c1864906fea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
using System;
using System.Linq;
namespace IOL.Helpers
{
public static class RandomString
{
private static readonly Random _random = new Random();
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());
}
}
}
|