1Algorithm::CheckDigits:U:sMe1r1_C0o1n2t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M11_012(3)
2
3
4
6 CheckDigits::M11_012 - compute check digits for
7 Bundeswehrpersonenkennnummer (DE)
8
10 use Algorithm::CheckDigits;
11
12 $bwpk = CheckDigits('bwpk_de');
13
14 if ($bwpk->is_valid('151058-D-20711')) {
15 # do something
16 }
17
18 $cn = $bwpk->complete('151058-D-2071');
19 # $cn = '151058-D-20711'
20
21 $cd = $bwpk->checkdigit('151058-D-20711');
22 # $cd = '1'
23
24 $bn = $bwpk->basenumber('151058-D-20711');
25 # $bn = '151058-D-2071';
26
28 ALGORITHM
29 1. Beginning left all digits are weighted 2,3,4,5,6,7,1,6,7,2,3.
30 Letters are replaced according to the following table:
31
32 my %table_to = (
33 A => 12, B => 14, C => 16, D => 18, E => 20,
34 F => 22, G => 24, H => 26, I => 28, J => 6,
35 K => 8, L => 10, M => 12, N => 14, O => 16,
36 P => 18, Q => 20, R => 22, S => 4, T => 6,
37 U => 8, V => 10, W => 12, X => 14, Y => 16,
38 Z => 18,
39 );
40
41 2. The weighted digits are added.
42
43 3. The sum from step 2 is taken modulo 11.
44
45 4. The checksum is 11 minus the sum from step 3.
46
47 If the difference is 10, the checkdigit is 0.
48
49 If the difference is 11, the checkdigit is 1.
50
51 METHODS
52 is_valid($number)
53 Returns true only if $number consists solely of numbers, letters
54 and hyphens and the rightmost digit is a valid check digit
55 according to the algorithm given above.
56
57 Returns false otherwise,
58
59 complete($number)
60 The check digit for $number is computed and appended to the end of
61 $number.
62
63 Returns the complete number with check digit or '' if $number does
64 not consist solely of digits, hyphens and spaces.
65
66 basenumber($number)
67 Returns the basenumber of $number if $number has a valid check
68 digit.
69
70 Return '' otherwise.
71
72 checkdigit($number)
73 Returns the check digits of $number if $number has valid check
74 digits.
75
76 Return '' otherwise.
77
78 EXPORT
79 None by default.
80
82 Mathias Weidner, "<mamawe@cpan.org>"
83
85 perl, CheckDigits, www.pruefziffernberechnung.de,
86
87
88
89perl v5.32.0 2020-07-28Algorithm::CheckDigits::M11_012(3)