Take a valid credit card number, such as
4111-1111-1111-1111, change it slightly, to
4111-2111-1111-1111, and it ceases to be valid. This is because the last digit of the number is a checksum calculated from the preceding digits via the Luhn algorithm. It’s not particularly clever; it’s not cryptographically secure. It’s not meant to be. What it’s intended to do is to protect against accidental data entry errors, and it does that very well.