public static void Main()
for (int i=0; i<100; i++)
Console.WriteLine(string.Format("NID {0} {1} {2}", n, ToNID(n), FromNID(ToNID(n))));
private const string NID_CHRS = "HQWKZCXPGSVTBLRMNJFD";
private const int NID_BASE = 20;
private const int NID_MIN = 1337;
public static string ToNID(int n)
s = NID_CHRS[sum % NID_BASE] + s;
public static int FromNID(string s)
s = s.Trim().ToUpperInvariant();
throw new Exception("Empty ID");
for (int i = 1; i < s.Length; i++)
var ci = NID_CHRS.IndexOf(c);
for (int j = s.Length - i - 1; j > 0 ; j--)
throw new Exception("Invalid ID");
if (s[0] != NID_CHRS[sum % NID_BASE])
throw new Exception("Invalid ID");