How To Calculate The Letter Of The Electronic DNI

One of the most important documents that a citizen has is the electronic DNI or DNI-E, which is a digital version of the classic national identity document . However, many people have no idea how to use it or the benefits of taking the time to obtain it, as they think that it is something that only entrepreneurs need. Here you will learn what the DNIe is and how to calculate the letter of the electronic DNI.

You should know that one of the most fundamental elements of this document is the letter, which is an alphabetical value right at the end of the identification number. This letter is used as a means of verification to make sure that the number in front is correct and accurate, so that it is not placed randomly.

Index of contents

How to calculate the letter of the electronic DNI?

There are several ways to obtain this letter, which is determined by an algorithm in which the numerical value is divided by 23 and the result is changed to a letter. This is what the authorities do when printing a physical document, although how is it done with the digital version ?

That is what you are going to learn in this guide, we are going to show you how to get the letter of the electronic DNI, and we are also going to tell you what this document is and why it is so important that you have it so that you can take advantage of the advantages that carries.

What is the electronic DNI and how does it benefit the Spanish?

The DNI-E is the electronic version of the popular national identity document that allows the verification of the identity of the bearer when carrying out procedures through the Internet . In a certain way, it is like a digital signature that allows you to do legal procedures before national organizations such as the Treasury or Social Security , in such a way that you do not have to leave your home and wait for hours sitting in an office.

This identity document has many advantages because financial institutions can verify your data, which facilitates the exchange of information. One of the advantages of this technology is that you can access your bank account remotely, using your fingerprint as an identification element.

You should know that this tool allows you to easily sign documents in PDF or Microsoft Word format. By using it, everyone knows that you yourself were the person who performed the procedure. The DNI always guarantees your identity , reducing the risk of fraud and promoting the use of electronic means because technology is almost non-existent.

To use this technology, you need to install software designed for Windows, Linux and MacOS operating systems on your PC. If for some reason your platform is that of the Penguin or the Manzanita, you will need to use the OpenDNIe application for it to work, but in general it is very simple to use on all platforms.

Steps to verify and calculate the letter of a person’s DNI

Being able to calculate the letter of the electronic DNI (DNI-E) is one of the simplest tasks, as we have already told you, all you have to do is separate your identification number and given the rest you will be assigned a letter.

These letters are different and are not in alphabetical order, although you can find out from the following table:

  • If the remainder is 0Letter T .
  • If the remainder is equal to 1, the letter R .
  • If the remainder is equal to 2, the letter W .
  • If the remainder is equal to 3, the letter A .
  • If the remainder is equal to 4, the letter G .
  • If the remainder is 5, the letter M corresponds .
  • If the remainder is equal to 6, the letter Y corresponds .
  • If the remainder is equal to 7, the letter F .
  • If the remainder is equal to 8, the letter P .
  • If the remainder is equal to 9, the letter D .
  • If the remainder is 10, the letter X corresponds .
  • If the remainder is 11, the letter B .
  • If the remainder is equal to 12, letter N .
  • If the remainder is equal to 13, the letter J .
  • If the remainder is equal to 14, the letter Z corresponds .
  • If the remainder is equal to 15, letter S .
  • If the remainder is equal to 16, corresponding to the letter Q .
  • If the remainder is equal to 17, corresponding to the letter V .
  • If the remainder is equal to 18, corresponding to the letter H .
  • If the remainder is equal to 19, the letter L .
  • If the remainder is equal to 20, corresponding to the letter C .
  • If the remainder is equal to 21, the letter K .
  • If the remainder is equal to 22, corresponding to the letter E .

And the foreigners? You should know that foreigners residing in Spain have a NIF composed of a letter, it can be X, Y or Z, a 7-digit number and also a control code. The latter is defined in the same way as the letter of the DNI; It is divided by 23 and a unique code is determined from the result .

1- Online tools

With the help of programs you can yourself calculate the letter of the DNI (national identity document) or the letter NIF (tax identification number). So, you should do the following:

  1. Access the link on this site .
  2. This information appears on the screen:
  3. Write your DNI / NIF in the box and press ” Calculate Letter“.
  4. Next, he throws you your identification card with the corresponding letter. And that’s it.

Other online tools are very similar in their functionality, we are going to leave you the URLs so that you can visit them and do the calculation in the way that works best for you.

  1. com / textcalculadoranif.htm
  2. en / utilities / calculate-ID-letter
  3. site / letter-dni

2- Using a mathematical algorithm

To perform this procedure, it is essential to have some knowledge of algorithms and programming, and to have a development environment program such as Eclipse and the Java Runtime Environment (JRE) that provides the ability to do coding. But don’t worry, we’ll tell you the codes and that’s it. You must have ideas on how to do the DNI / NFI calculation using a different method.

  1. You have to remember what you learned in Excel. Regarding the procedure for using the formula. Remember: “When the rest of the complete division of cell A2 by 23 is calculated and one is added to it, and the letter assigned to the DNI has to be specified” or what is the same; EXTRACT (“TRWAGMYFPDXBNJZSQVHLCKE”; WASTE (A2; 23) +1; 1)
  2. View the table of letters of the DNI, this is what the algorithm will do when you run the program.
  3. You must proceed to the coding in JAVA language. The algorithm will do the same as the Excel function; calculate modulo 23 in your identification number.
  4. Later, to get the letter: You must run a string that will belong to the letters in order, so you can use charAt (module) to calculate the letter that corresponds to the specified position. Now you will see the java code that performs the calculation:

Do not forget that to calculate the letter of the electronic DNI in this way you have to have basic knowledge of programming. You can go to a computer science institute or academy and ask a certified computer scientist to run the code. The result will be a list of DNI with the corresponding letter.

3- Excel spreadsheet

You can calculate the letter of the electronic DNI by means of an Excel spreadsheet. The Microsoft Office Excel tool gives you many functions, and there is one that facilitates the calculation of the DNI / NIF.

The procedure is as follows:

  1. It all starts with the function modulo 23, which works as an integer.
  2. This is similar to the others; when doing all the division of the DNI between the number 23.
  3. When using this Excel function, the result will be between 0 and 22.

The number 14 that appears on the screen in this case is called the result, then you must place the letters in the following order: TRWAGMYFPDXBNJZSQVHLCKE . Although … Why is this order followed and not all the letters of the alphabet?

  1. Well, the main reason is that the letters I, O, Ñ and U were not included. The first two are designed to avoid errors and confusion, so that they are not interpreted as numbers 1 and 0. In the case of the letter Ñ it was not used because it was not used in other European countries, and in the case of the letter U , so that it is not compared or confused with V.
  2. Since the result of the previous division is 14, the process of counting spaces begins, for example, for the DNI ” 12345678” its letter is Z.
  3. You must start with 0 instead of 1 and the result will be in the correct order, which is Z, the fourteenth letter of the order that we have given you before. We suggest you run this example using the online tools shown above and verify the result.

To be able to apply all this in Excel, you need to do the following:

  1. You have to open an excel sheet to add the formula.
  2. Then, you go to the cells and generate a column for the DNI list and next to the column of numbers you generate another for the result with a letter.
  3. Then you will calculate the letter using this formula, do not forget that you only need to use module 23 + the order of the letter.
  4. And I would leave you with something like this:
  5. EXTRACT (“TRWAGMYFPDXBNJZSQVHLCKE”; WASTE (A2; 23) +1; 1)
  6. Which in Spanish means: ” When calculating the rest of the complete division of cell A2 by 23 and adding one, you must indicate the letter established for the DNI“.

Due to the functionality of the Excel functions that have a remainder between rows, it directly calculates the remainder of the entire division of the DNI / 23. Then take into account the +1, because Excel always starts with 1, not with zero (0) .

This will end as seen in the next image:

  1. Excel will allow you to combine the DNI and the letter, in a few words you will combine the numbers with the letter.
  2. You must write the following formula: = CONCATENATE (A2; EXTRACT (“TRWAGMYFPDXBNJZSQVHLCKE”; RESIDUE (A2; 23) +1; 1))

This will result in what you see in the following screen:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top