LeaDerLyCa
New member
- Katılım
- 25 May 2007
- Mesajlar
- 7,890
- Reaction score
- 0
- Puanları
- 0
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"%>
<form action="tckimlik.asp" method="get">
Tckimlik Numarası Giriniz : <input type="text" name="query"> <input type="submit">
</FORM>
<%
if request("query") <> "" then
if len(request("query")) = 11 then
dim tckimlikdize(11)
response.write "<hr/>"
for i = 1 to 11
tckimlikdize(i) = mid(request("query"),i,1)
response.write tckimlikdize(i) & " // "
next
response.write "<hr/>"
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 "<P><STRONG><FONT COLOR=BLUE>!!!!!!!!!!!! Geçerli !!!!!!!!!!!!!!!</FONT></STRONG></P>"
ELSE
Response.write "<P><STRONG><FONT COLOR=RED>!!!!!!!!!!!! Geçersiz !!!!!!!!!!!!!!!</FONT></STRONG></P>"
END if
response.write "<hr/>"
response.write "Tekler = " & tekler & "<br>"
response.write "Çiftler = " & ciftler & "<br>"
response.write "T1= " & t1 & "<br>"
response.write "T2 = " & t2 & "<br>"
response.write "T3 = " & t3 & "<br>"
response.write "C1=" & c1 & "<->" & tckimlikdize(10) & "</br>"
response.write "C2=" & c2 & "<->" & tckimlikdize(11) & "</br>"
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"%>
<form action="tckimlik.asp" method="get">
Tckimlik Numarası Giriniz : <input type="text" name="query"> <input type="submit">
</FORM>
<%
if request("query") <> "" then
if len(request("query")) = 11 then
dim tckimlikdize(11)
response.write "<hr/>"
for i = 1 to 11
tckimlikdize(i) = mid(request("query"),i,1)
response.write tckimlikdize(i) & " // "
next
response.write "<hr/>"
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 "<P><STRONG><FONT COLOR=BLUE>!!!!!!!!!!!! Geçerli !!!!!!!!!!!!!!!</FONT></STRONG></P>"
ELSE
Response.write "<P><STRONG><FONT COLOR=RED>!!!!!!!!!!!! Geçersiz !!!!!!!!!!!!!!!</FONT></STRONG></P>"
END if
response.write "<hr/>"
response.write "Tekler = " & tekler & "<br>"
response.write "Çiftler = " & ciftler & "<br>"
response.write "T1= " & t1 & "<br>"
response.write "T2 = " & t2 & "<br>"
response.write "T3 = " & t3 & "<br>"
response.write "C1=" & c1 & "<->" & tckimlikdize(10) & "</br>"
response.write "C2=" & c2 & "<->" & tckimlikdize(11) & "</br>"
else
response.write "11 hane olmalı"
end if
end if
%>
Bu Ornek ASP kodudur