A simple utility tool for generating and validating Turkish National Identity Numbers (TCKN).
go install github.com/Armageddon0x00/tckngen@latest
git clone https://github.com/Armageddon0x00/tckngen
cd tckngen
go install .
tckngen generate 5
tckngen generate 5 nobanner
You can pipe this to a file to generate example dataset.
tckngen generate endless nobanner
tckngen validate 12345678901
tckngen validate exampleNumbers.txt
tckngen validate exampleNumbers.txt valid nobanner
tckngen validate exampleNumbers.txt invalid nobanner
Validate and generate TCKN using Bash. Useful for offline and slow needs.
tckncheck() {
local RED="\e[31m"
local ENDCOLOR="\e[0m"
local GREEN="\e[32m"
local TCKN="$1"
local Pattern="^[0-9]{11}$"
if [[ $TCKN =~ $Pattern ]]; then
if [ "${TCKN:0:1}" -eq 0 ]; then
echo -e "${RED} [-] TCKN not valid. $TCKN ${ENDCOLOR}"
fi
local odd=$(( ${TCKN:0:1} + ${TCKN:2:1} + ${TCKN:4:1} + ${TCKN:6:1} + ${TCKN:8:1} ))
local even=$(( ${TCKN:1:1} + ${TCKN:3:1} + ${TCKN:5:1} + ${TCKN:7:1} ))
local 10th_validator=$(( (odd * 7 - even) % 10 ))
local sum=$(( (odd + even + ${TCKN:9:1}) % 10 ))
if [ $10th_validator -ne ${TCKN:9:1} ]; then
echo -e "${RED} [-] TCKN not valid. $TCKN ${ENDCOLOR}"
fi
if [ $sum -ne ${TCKN:10:1} ]; then
echo -e "${RED} [-] TCKN not valid. $TCKN ${ENDCOLOR}"
else
echo -e "${GREEN} [+] TCKN is valid. $TCKN ${ENDCOLOR}"
fi
else
echo -e "${RED} [-] TCKN not valid. $TCKN ${ENDCOLOR}"
fi
}
TODO
- Fix endless generation function (1/50000 error rate?)
- Add more validation options (only show valid - invalid)
- Improve generation algorithm (no duplicates in same generation, more randomness etc.)
- More parsing options
- Usable library functions ?
- KISS and Clean.
- Bash function for TCKN generation.
Sidenote: This was meant to be a simple hourly project. Now I'm invested.