What are the current algorithms for checking the credit card number for validity by calculating the checksum and whether they have a implementation in Python.

  • 2
    Moon algorithm - KoVadim
  • I read that he makes mistakes - LorDo
  • Yes, admits. Roughly coarse, the last digit is just the previous hashsum. Since the set of 15 digits is much more than 10, then errors are normal. - KoVadim pm
  • @LorDo he simply confirms that the selected sequence of numbers has the right to be a card number. Do you want an algorithm capable of verifying that a card was issued simply on the basis of mathematical calculations? It's impossible. - etki
  • I am quite satisfied with what he is doing at the moment, I just would like to minimize the probability of an error, can I use the Verhuffa Algorithm for these purposes? - LorDo

1 answer 1

CRC or cyclic redundancy code is designed to verify data integrity. There are many different variations on this topic, as well as their combinations. The simplest algorithm is used to calculate a barcode check digit.

  1. Dialing numbers are numbered from right to left.
  2. Calculate the sum of the numbers standing on even and odd places.
  3. The sum of the figures standing in even places is added to the tripled sum of the figures standing in odd places.
  4. If the number of units of the result obtained is zero, then the check digit is 0. If the last digit of the result is not zero, then the check digit is equal to the addition of this digit to 10.