CSharp · Console
using System;
using System.Linq;
using System.Security.Cryptography;
public class Program
{
public static void Main()
{
var x = 100;
while (x-- > 0)
Console.WriteLine(Generate());
}
public static string Generate(int length = 7)
{
var rng = new RNGCryptoServiceProvider();
var buff = new byte[length];
var result = string.Empty;
do
{
rng.GetBytes(buff);
for (int i = 0; i < length && result.Length < length; i++)
{
var c = buff[i] & 0x1F;
if (c < 26)
result += (char)(result.Length == 0 || result[result.Length - 1] != c ? c : (c + 1) % 26);
}
} while (result.Length < length);
return string.Join(string.Empty, result.Select(b => (char)(97 + b)));
}
}