Algoritmul il puteti gasi aici http://www.validari.ro/cnp
codul C# scris de mine este:
bool VerificaCNP(string cnp)
{
if (cnp.Length != 13)
return false;
const string a = "279146358279";
long j = 0;
if (!long.TryParse(cnp, out j))
return false;
long suma = 0;
for (int i = 0; i < 12; i++)
suma += long.Parse(cnp.Substring(i, 1)) * long.Parse(a.Substring(i, 1));
long rest = suma - 11 * (int)(suma / 11);
rest = rest == 10 ?
1 : rest;
if (long.Parse(cnp.Substring(12, 1)) != rest)
return false;
return true;
}
Algoritmul a fost implementat aici http://cnp.cetatenie-romana.info