using System.Text;
using System.Threading.Tasks;

namespace ZSB.Infrastructure.ProductKey.Generator
{
    class UniqueKeyGenerator
    {
        private static RandomNumberGenerator rng = RandomNumberGenerator.Create();
        public static string GenerateUniqueKey(string prefix, string allowedCharacters, int charCount)
        {
            byte[] indices = new byte[charCount - prefix.Length];
            rng.GetBytes(indices);
            string result =
                new string(indices.Select(a => a % allowedCharacters.Length).Select(a => allowedCharacters[a]).ToArray());
