Twelve data digits and one check digit
An EAN-13 value contains twelve data digits followed by a checksum. Starting from the rightmost data digit, multiply alternate digits by 3 and 1. Add the results. The check digit is the amount needed to reach the next multiple of ten, or zero if the sum is already divisible by ten.
A worked example
For 590123412345, the weighted sum is 83. The next multiple of ten is 90, so the check digit is 7. The complete value is 5901234123457. The generator accepts the twelve data digits and appends 7, or accepts the complete value and validates it. It rejects a supplied incorrect final digit instead of silently changing your identifier.
What the checksum does not tell you
A checksum detects some data-entry errors; it does not prove that GS1 assigned a number or that you may use it commercially. Obtain an appropriate identifier through the relevant GS1 process and follow packaging and retailer requirements. Independent print verification is separate from numerical validation.