1Algorithm::CheckDigits:U:sMe1r0_C0o0n1t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M10_001(3)
2
3
4
6 CheckDigits::M10_001 - compute check digits for Bahncard (DE), IMEI,
7 IMEISV, ISIN, Miles&More, Payback (DE), Personnummer (SE), Passport
8 (BR), Credit Cards, SSN (US), Samordningsnummer (SE), VAT RN (ES), VAT
9 RN (IT), VAT RN (SE), International Securities Identifikation Number
10 (ISIN), CUSIP
11
13 use Algorithm::CheckDigits;
14
15 $visa = CheckDigits('visa');
16
17 if ($visa->is_valid('4111 1111 1111 1111')) {
18 # do something
19 }
20
21 $cn = $visa->complete('4111 1111 1111 111');
22 # $cn = '4111 1111 1111 1111'
23
24 $cd = $visa->checkdigit('4111 1111 1111 1111');
25 # $cd = '7'
26
27 $bn = $visa->basenumber('4111 1111 1111 1111');
28 # $bn = '4111 1111 1111 111'
29
31 ALGORITHM
32 1. Beginning right all numbers are weighted alternatively 1 and 2
33 (that is the check digit is weighted 1).
34
35 2. The total of the digits of all products is computed.
36
37 3. The sum of step 3 ist taken modulo 10.
38
39 4. The check digit is the difference between 10 and the number from
40 step 3.
41
42 To validate the total of the digits of all numbers inclusive check
43 digit taken modulo 10 must be 0.
44
45 METHODS
46 is_valid($number)
47 Returns true only if the last digit is a valid check digit
48 according to the algorithm given above.
49
50 Returns false otherwise,
51
52 If the checked number is of type CUSIP, the number must be exact 9
53 digits or letters long and must not have spaces in between.
54
55 complete($number)
56 The check digit for $number is computed and concatenated to the end
57 of $number.
58
59 Returns the complete number with check digit or '' if $number does
60 not consist solely of digits and spaces.
61
62 basenumber($number)
63 Returns the basenumber of $number if $number has a valid check
64 digit.
65
66 Return '' otherwise.
67
68 checkdigit($number)
69 Returns the checkdigit of $number if $number has a valid check
70 digit.
71
72 Return '' otherwise.
73
74 EXPORT
75 None by default.
76
78 Mathias Weidner, "<mamawe@cpan.org>"
79
81 perl, Algorithm::CheckDigits, www.pruefziffernberechnung.de.
82 http://en.wikipedia.org/wiki/CUSIP
83
84 For IMEI, IMEISV: ETSI Technical Specification TS 100 508 (v6.2.0)
85
86
87
88perl v5.30.1 2020-01-29Algorithm::CheckDigits::M10_001(3)