CLABE

The CLABE (Clave Bancaria Estandarizada, Spanish for "standardized banking cipher" or "standardized bank code") is a banking standard for the numbering of bank accounts in Mexico. This standard is a requirement for the sending and receiving of domestic inter-bank electronic funds transfer since June 1, 2004.

The CLABE replaces the Mexican account numbering scheme where the account number has 11 digits, when it comes to electronic transfers. The provision for CLABE standardization was issued by the Asociación de Bancos de México (ABM) (Mexican Bank Association) in conjunction with the Banco de México (Mexico's Central Bank). It ensures that the inter-bank fund transfers, payroll deposits, or automatic service charges are made to the correct accounts.

Structure
The 18 digits of the CLABE follows this structure:


 * 3 Digits: Bank Code
 * 3 Digits: Branch Office Code
 * 11 Digits: Account Number
 * 1 Digit : Control Digit

Bank code
In Mexico, banking institutions are identified by a three-digit number assigned by the ABM. The following table is a Bank Catalogue provided by El Servicio de Administración Tributaria (SAT.gob.mx), as of December 4, 2014:

City code
This three-digit code refers to the city ("Plaza") where the checking account is located is interna. A bank can have several Branches in a city, therefore the number of the Branch is included in the next, eleven digit section for the checking account number.

Account number
The account number in the financial institution, padded on the left with zeroes to a width of 11 digits.

Control digit
The control digit is calculated as the modulus 10 of 10 minus the modulus 10 of the sum of the modulus 10 of the product of the first 17 digits by its weight factor.

The first 17 digits of the CLABE are, as mentioned above, the Bank Code, the Branch Office Code and the Account Number.

The weight factor of a given digit is:


 * 3 if its position (starting at 0) modulus 3 is 0
 * 7 if its position modulus 3 is 1
 * 1 if its position modulus 3 is 2

A 17 digit weight is always "37137137137137137".

The method is:


 * For every digit, multiply it by its weight factor and take their modulus 10 (modulus is the Remainder of the integer division. The modulus X of a baseX number is its rightmost digit).
 * Sum all of the calculated products, and take modulus 10 again.
 * Subtract the sum to 10, take modulus 10, and you have the resulting control digit.

So, as an example:

And so, the complete CLABE is: 032180000118359719