public static string GetUniqueIndentifier(int length)
{
if (length <= 0)
{
return(string.Empty);
}
int maxSize = length;
char[] chars = new char[62];
string a = "abcdefghijklmnopqrstuvwxyz1234567890";
chars = a.ToCharArray();
int size = maxSize;
byte[] data = new byte[1];
System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
rng.GetNonZeroBytes(data);
size = maxSize;
data = new byte[size];
rng.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder();
foreach (byte b in data)
{
result.Append(chars[b % (chars.Length - 1)]);
}
if (result[0] >= '0' && result[0] <= '9')
{
return(GetUniqueIndentifier(length));
}
return(result.ToString());
}