-
-
Save serkankaya/b4b6823ddc9d656df419a38f2546076e to your computer and use it in GitHub Desktop.
Java / Android TC Kimlik No Doğrulama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Yalnızca UI onayı için kullanılmalıdır | |
// İş önemi olan durumlarda bu api'yi kullanmalısınız: | |
// https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?op=TCKimlikNoDogrula | |
private boolean isTCKNCorrect(String id) { | |
if (id == null) return false; | |
if (id.length() != 11) return false; | |
char[] chars = id.toCharArray(); | |
int[] a = new int[11]; | |
for(int i=0; i<11; i++) { | |
a[i] = chars[i] - '0'; | |
} | |
if(a[0] == 0) return false; | |
if(a[10] % 2 == 1) return false; | |
if(((a[0] + a[2] + a[4] + a[6] + a[8]) * 7 + (a[1] + a[3] + a[5] + a[7]))*9 % 10 != a[9]) return false; | |
if((a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]) % 10 != a[10]) return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment