using System.Security.Cryptography;
public static void Main()
var password = RandomString(15);
Console.WriteLine("value: " + password);
static string RandomString(int length)
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder res = new StringBuilder();
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
byte[] uintBuffer = new byte[sizeof(uint)];
rng.GetBytes(uintBuffer);
uint num = BitConverter.ToUInt32(uintBuffer, 0);
res.Append(valid[(int)(num % (uint)valid.Length)]);