Tckimlik numarası kendi rakamları arasında tutarlı bir algoritma ile dogrulanabilir. Örneğin offline bir uygulama geliştirmektesiniz ve bura...
Tckimlik numarası kendi rakamları arasında tutarlı bir algoritma ile dogrulanabilir. Örneğin offline bir uygulama geliştirmektesiniz ve burada tckimlik numarası girildiğinde doğrulama yapmak istiyorsunuz (Tckimlik numarasın web servisleri ile sorgulama anlamına gelmemektedir).
Algoritma:
TC Kimlik numaramız 11 basamaklı ve her bir rakamı kn ile ifade edelim
TC no: k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 olsun.
tekler = k1+k3+k5+k7+k9
çiftler = k2+k4+k6+k8 (dikkat k10 yok!)
TC kimlik numarasının son iki basamağı (k10 ve k11) kontrol amaçlıdır.
Şimdi o kontrolü yapmak için aşağıdaki işlemler yapılır:
İşlemler:
t1 = (tekler*3)+çiftler
c1 = (10 - (t1 mod10))mod10
t2 = c1 + çiftler
t3 = (t2*3)+tekler
c2 = (10 - (t3 mod10))mod10
Eğer,
c1 = k10 (yani Tc nonun 10.basamağı) ve c2=k11 (yani son basamak)
ozaman bu TC kimlik numarası geçerlidir denir.
Örnek Asp Kodu :
<%="HYTGNY"%>
<%
if request("query") <> "" then
if len(request("query")) = 11 then
dim tckimlikdize(11)
response.write "
"
for i = 1 to 11
tckimlikdize(i) = mid(request("query"),i,1)
response.write tckimlikdize(i) & " // "
next
response.write "
"
tekler = int(tckimlikdize(1)) + int(tckimlikdize(3)) + int(tckimlikdize(5)) + int(tckimlikdize(7)) + int(tckimlikdize(9))
ciftler = int(tckimlikdize(2)) + int(tckimlikdize(4)) + int(tckimlikdize(6)) + int(tckimlikdize(8))
t1 = (int(tekler)*3) + int(ciftler)
c1 = (10 - (int(t1) mod 10)) mod 10
t2 = int(c1) + int(ciftler)
t3 = (int(t2)*3) + int(tekler)
c2 = (10 - (int(t3) mod 10)) mod 10
if (CSTR(c1)= CSTR(tckimlikdize(10))) And (CSTR(c2)= CSTR(tckimlikdize(11))) then
Response.write "!!!!!!!!!!!! Geçerli !!!!!!!!!!!!!!!
"
ELSE
Response.write "!!!!!!!!!!!! Geçersiz !!!!!!!!!!!!!!!
"
END if
response.write "
"
response.write "Tekler = " & tekler & "
"
response.write "Çiftler = " & ciftler & "
"
response.write "T1= " & t1 & "
"
response.write "T2 = " & t2 & "
"
response.write "T3 = " & t3 & "
"
response.write "C1=" & c1 & "<->" & tckimlikdize(10) & ""
response.write "C2=" & c2 & "<->" & tckimlikdize(11) & ""
else
response.write "11 hane olmalı"
end if
end if
%>
Bu Ornek ASP kodudur->->
Algoritma:
TC Kimlik numaramız 11 basamaklı ve her bir rakamı kn ile ifade edelim
TC no: k1 k2 k3 k4 k5 k6 k7 k8 k9 k10 k11 olsun.
tekler = k1+k3+k5+k7+k9
çiftler = k2+k4+k6+k8 (dikkat k10 yok!)
TC kimlik numarasının son iki basamağı (k10 ve k11) kontrol amaçlıdır.
Şimdi o kontrolü yapmak için aşağıdaki işlemler yapılır:
İşlemler:
t1 = (tekler*3)+çiftler
c1 = (10 - (t1 mod10))mod10
t2 = c1 + çiftler
t3 = (t2*3)+tekler
c2 = (10 - (t3 mod10))mod10
Eğer,
c1 = k10 (yani Tc nonun 10.basamağı) ve c2=k11 (yani son basamak)
ozaman bu TC kimlik numarası geçerlidir denir.
Örnek Asp Kodu :
<%="HYTGNY"%>
<%
if request("query") <> "" then
if len(request("query")) = 11 then
dim tckimlikdize(11)
response.write "
"
for i = 1 to 11
tckimlikdize(i) = mid(request("query"),i,1)
response.write tckimlikdize(i) & " // "
next
response.write "
"
tekler = int(tckimlikdize(1)) + int(tckimlikdize(3)) + int(tckimlikdize(5)) + int(tckimlikdize(7)) + int(tckimlikdize(9))
ciftler = int(tckimlikdize(2)) + int(tckimlikdize(4)) + int(tckimlikdize(6)) + int(tckimlikdize(8))
t1 = (int(tekler)*3) + int(ciftler)
c1 = (10 - (int(t1) mod 10)) mod 10
t2 = int(c1) + int(ciftler)
t3 = (int(t2)*3) + int(tekler)
c2 = (10 - (int(t3) mod 10)) mod 10
if (CSTR(c1)= CSTR(tckimlikdize(10))) And (CSTR(c2)= CSTR(tckimlikdize(11))) then
Response.write "!!!!!!!!!!!! Geçerli !!!!!!!!!!!!!!!
"
ELSE
Response.write "!!!!!!!!!!!! Geçersiz !!!!!!!!!!!!!!!
"
END if
response.write "
"
response.write "Tekler = " & tekler & "
"
response.write "Çiftler = " & ciftler & "
"
response.write "T1= " & t1 & "
"
response.write "T2 = " & t2 & "
"
response.write "T3 = " & t3 & "
"
response.write "C1=" & c1 & "<->" & tckimlikdize(10) & ""
response.write "C2=" & c2 & "<->" & tckimlikdize(11) & ""
else
response.write "11 hane olmalı"
end if
end if
%>
Bu Ornek ASP kodudur->->
COMMENTS