EAN-13 (European Article Number) is the 13-digit barcode you'll find on almost every retail product worldwide. Each digit has a job.
Take the barcode 4610017121214. It breaks down like this:
461) are the GS1 prefix, here registered in Russia.4) is a checksum of the first twelve.Open any product page and you'll see this breakdown drawn out and colour-coded, with the check digit verified.
Multiply the digits in odd positions by 1 and even positions by 3, add them up, and the check digit is whatever makes the total a multiple of 10. If a scan doesn't satisfy this, the read is rejected — which is why a mistyped code shows as invalid.
UPC-A (12 digits, common in North America) is really an EAN-13 with a leading zero — see UPC-A vs EAN-13. EAN-8 is a shortened 8-digit version for small packaging.