1CheckDigits::M10_001(3)User Contributed Perl DocumentatioCnheckDigits::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)
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 $number consists solely of numbers and the
48 last digit is a valid check digit according to the algorithm given
49 above.
50
51 Returns false otherwise,
52
53 complete($number)
54 The check digit for $number is computed and concatenated to the end
55 of $number.
56
57 Returns the complete number with check digit or '' if $number does
58 not consist solely of digits and spaces.
59
60 basenumber($number)
61 Returns the basenumber of $number if $number has a valid check
62 digit.
63
64 Return '' otherwise.
65
66 checkdigit($number)
67 Returns the checkdigit of $number if $number has a valid check
68 digit.
69
70 Return '' otherwise.
71
72 EXPORT
73 None by default.
74
76 Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
77
79 perl, CheckDigits, www.pruefziffernberechnung.de.
80
81 For IMEI, IMEISV: ETSI Technical Specification TS 100 508 (v6.2.0)
82
83
84
85perl v5.12.1 2009-11-20 CheckDigits::M10_001(3)