La clabe bancaria estandarizada de Mexico #mx se compone de 18 dígitos.
El último es la suma de validación de los 17 dígitos previos, este se genera por un algoritmo.
Para esta implementación me base de un PDF que venia de referencia en la Wikipedia en donde en su página 18 describe este algoritmo, dejo el enlace: