The Turkish National Identity Number (TC Kimlik No) is a unique 11-digit number assigned to Turkish citizens. It is generated based on personal information such as name, surname, and date of birth, along with some algorithmic rules.
🔐 Structure & Rules for Turkish National ID (TC Kimlik No):
- Length: 11 digits.
- First digit: Cannot be zero.
- Odd-positioned digits (1st, 3rd, ..., 9th):
- Sum the digits at odd positions (excluding the 11th).
- Even-positioned digits (2nd, 4th, ..., 10th):
- Sum the digits at even positions (excluding the 10th).
- Tenth digit:
(Sum of odd digits * 7 - sum of even digits) % 10
- Eleventh digit:
(Sum of first 10 digits) % 10
Note: In real-world applications, additional data like name, surname, and date of birth are used in an internal hash function by the government. This public algorithm mimics the check digit logic only and cannot generate valid IDs tied to individuals. It's useful for validation or generating mock IDs that follow the format.
🧮 Python Script to Generate Valid Format TC Numbers (Mock IDs)
This script can be used to generate valid-format TC numbers, and optionally create "related" IDs (e.g., family members) by varying certain parameters.
import random
def generate_tc_number():
# First 9 digits
digits = [random.randint(0, 9) for _ in range(9)]
digits[0] = random.randint(1, 9) # First digit can't be zero
# Calculate 10th digit
odd_sum = sum(digits[i] for i in range(0, 9, 2)) # Positions 0,2,4,6,8 (1st,3rd,...9th)
even_sum = sum(digits[i] for i in range(1, 8, 2)) # Positions 1,3,5,7 (2nd,4th,...8th)
tenth_digit = (odd_sum * 7 - even_sum) % 10
digits.append(tenth_digit)
# Calculate 11th digit
eleventh_digit = sum(digits) % 10
digits.append(eleventh_digit)
return ''.join(map(str, digits))
def generate_related_ids(base_id=None, count=5):
related_ids = []
if base_id:
# Use the first 9 digits from base ID
base_digits = list(map(int, base_id[:9]))
else:
base_digits = None
for _ in range(count):
if base_digits:
# Slightly modify one digit in the first 9 digits
temp_digits = base_digits[:]
idx = random.randint(0, 8)
temp_digits[idx] = (temp_digits[idx] + random.randint(1, 9)) % 10
else:
temp_digits = [random.randint(0, 9) for _ in range(9)]
temp_digits[0] = random.randint(1, 9)
# Recalculate last two digits
odd_sum = sum(temp_digits[i] for i in range(0, 9, 2))
even_sum = sum(temp_digits[i] for i in range(1, 8, 2))
tenth = (odd_sum * 7 - even_sum) % 10
total_sum = sum(temp_digits) + tenth
eleventh = total_sum % 10
tc = ''.join(map(str, temp_digits + [tenth, eleventh]))
related_ids.append(tc)
return related_ids
# Example usage
if __name__ == "__main__":
base_id = generate_tc_number()
print("Base ID:", base_id)
relatives = generate_related_ids(base_id, 5)
print("\nRelated IDs:")
for rel_id in relatives:
print(rel_id)
📝 Output Example:
Base ID: 12345678902
Related IDs:
12345678910
12345678802
12345677902
12345668902
12345578902
⚠️ Disclaimer:
- These IDs are not linked to any real person.
- They follow the format and checksum rules, but they do not use real hashing or personal data.
- For legal compliance, never use generated IDs for official purposes.
Would you like this script adapted into another language (e.g., JavaScript, C#, PHP)?