String Keygen() { Byte[] key = new Byte[16] { 4, 4, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; Byte[] primes = new Byte[4] { 2, 3, 5, 7 }; while (true) { LOOP: for (Int32 i = 4; i < 16; i++) key[i] = (Byte)Random.Shared.Next(0, 10); if (key.Skip(4).Any(x => x == 4)) continue; if (key.Distinct().Count() < 5) continue; if (key.Count(x => x == 8) < 3) continue; if (key.Count(x => primes.Contains(x)) < 2) continue; Int32 sum = key.Sum(x => x switch { 0 => -14, 1 => -12, 2 => -8, 3 => -7, 4 => -3, 5 => -1, 6 => 2, 7 => 4, 8 => 8, 9 => 9 }); if (55 <= sum && sum <= 110) continue; for (Int32 i = 0; i < 82; i++) sum = (sum + i) % 110; if (sum < 55) continue; for (Int32 i = 4; i <= 12; i += 4) for (Int32 j = 0; j < 3; j++) if (key[i + j] == key[i + j + 1]) goto LOOP; break; } return key.Aggregate("", (a, b) => $"{a}{b}", s => s.Insert(12, "-").Insert(8, "-").Insert(4, "-")); }