Skip to content

Instantly share code, notes, and snippets.

@AlLiberali
Created June 4, 2025 13:56
Show Gist options
  • Save AlLiberali/cce6daed02e39d7cb6d13d3afa38f716 to your computer and use it in GitHub Desktop.
Save AlLiberali/cce6daed02e39d7cb6d13d3afa38f716 to your computer and use it in GitHub Desktop.

Revisions

  1. AlLiberali created this gist Jun 4, 2025.
    41 changes: 41 additions & 0 deletions 6675db88e7b35c09bb26703c.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    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, "-"));
    }