2023-05-07 20:00:00
Did you know that the letter that appears next to the set of numbers on your ID is not pure coincidence? Since 1955, the National Identity Document allows the recognition of each one of the Spanish citizens before the law, through a batch of digits accompanied by a letter. The number, for its part, is chosen from a total of values that the General Directorate of Police provides randomly to each of the police stations, from which the assignment is made to each citizen. However, the accompanying letter it’s not by chance.
The value of the alphabet that follows the numbers directly depends on them. That is, it is calculated from an algorithm that uses those numbers, relates them to a value of the alphabet and obtains one of the letters through that correspondence. This arithmetic method allows the detection of falsifications in the DNI, as well as the identification of possible errors in the assignment of the code.
CALCULATE THE DNI LETTER
The algorithm used to determine the letter of the DNI is known as linear congruence theorem and, outside of this legal and criminal context, it is used to describe cyclical processes, especially those related to the passage of time, such as hours or days. So, for example, as calendars are ways of measuring time in a cyclical way, they become an area of interest for work with congruences. The same is the case with watches.
This algorithm corresponds to a very important contribution by the physicist and mathematician Johann Carl Friedrich Gauss to Modular Arithmetic. In his famous book Disquisitiones Arithmeticae (Investigations into Arithmetic), Gauss proposes this theorem by stating that if an integer a divide the difference of the whole numbers b y cthen it will be said that b y c are congruent according to the module a.
The DNI uses the congruence modulo 23that is, the control digit, the letter, is obtained through the remainder of dividing the complete ID number by 23. Depending on what that remainder is, a specific letter is assigned according to a equivalence table. The reason that the value 23 is specifically used is that it is the number of possible letters to assign, since the entire alphabet is not fully worked with.
0 | T |
1 | R |
2 | W |
3 | A |
4 | G |
5 | M |
6 | Y |
7 | F |
8 | P |
9 | D |
10 | X |
11 | B |
12 | N |
13 | J |
14 | Z |
15 | S |
16 | Q |
17 | V |
18 | H |
19 | L |
20 | C |
21 | K |
22 | E |
As an example of this calculation, we could assume that the numerical code of a DNI is 17.003.989. If we divide this number by 23, we get a solution, that is, a quotient, of 739.303, with rest 20. Looking for that number 20 in the equivalence table, we see that it corresponds to the letter Cso that will be the one that accompanies the numerical code.
WHY ONLY 23 LETTERS?
When carrying out this correspondence between the rest of the division the letters, it is striking that not all of the letters of the alphabet are used, but solo 23. But why does this happen?
First, it was decided exclude I and O due to its great resemblance to 1 and 0, since they could give rise to errors and possible confusion in their writing. Besides, the Ñ was also removed of the options in order to avoid problems with the validity of the DNI abroad, since the character is exclusive to the Spanish language.
Thus, discarding those three for readability reasons, only 24 letters remain. However, not all of them are used because certain problems may arise in the calculation process: the number 24 has a large number of divisors and there could be two numbers with the same assigned letter. Therefore, the experts decided to eliminate another letter randomly and use 23 letters, being able to work with module 23, a Prime number that guarantees the reliability of process. In this case, the letter selected to be removed from the options was U.
OTHER METHODS AND APPLICATIONS
In addition to this curious application for calculating the security digit in the DNI, the congruence theorem is also used in other fields of the legal and security world. An example is its use in the IBAN generation of a bank account, which uses module 97, or in different systems of data cryptography as is, for example, the case of the Caesar cipher.
In the first case, to generate the IBAN code, 4 digits are added to the standard bank account number, two of which correspond to the country and two to the control number. If an individual is from Spain, ES00 will be written at the end of the 20 digits of the account. Subsequently, the E will be replaced by 14 and the S by 28. With the complete number obtained, the rest of the division by 97 is calculated and that result is subtracted from 98. The result is the IBAN control digit that will accompany the initials ES and that will replace that initial 00.
In the case of the Caesar cipher, a method of cryptography, the procedure consists of the displacement of certain squares in the alphabet, which is a direct method of the congruence theorem, since the last letters are again the first, creating a loop system. In this case, the algorithm would use a module 27 because, in the case of encrypting the Spanish language, it has an alphabet of 27 letters.
#letter #DNI #calculated