Algori...MXX_001(3pm)
๐ CheckDigits::MXX_001 โ it's giving check digits ๐
okay so bestie, welcome to Algori...MXX_001(3pm) from the User Contributed Perl Documentation โจ this one lives in the CheckDigits family (the Algorithm::CheckDigits girlies ๐) and she does exactly two jobs: she computes check digits for the german Personalausweis (pa_de) ๐ and for ABA routing numbers (aba_rn) ๐ฆ. lowkey iconic. let's get into it ๐
โจ NAME โจ
CheckDigits::MXX_001 โ compute check digits for german Personalausweis (pa_de) or ABA routing numbers (aba_rn) ๐ฆ
๐ธ SYNOPSIS ๐ธ
no cap, here's the whole vibe verbatim:
use Algorithm::CheckDigits;
$pa = CheckDigits('pa_de');
if ($pa->is_valid('2406055684D<<6810203<0705109<6')) {
# do something
}
if ($pa->is_valid('2406055684') {
# do_something
}
$cn = $pa->complete('240605568_D<<681020_<070510_<_');
# $cn = '2406055684D<<6810203<0705109<6'
$cd = $pa->checkdigit('2406055684D<<6810203<0705109<6');
# $cd = '6'
$bn = $pa->basenumber('2406055684D<<6810203<0705109<6');
# $bn = '240605568_D<<681020_<070510_<_'
$aba = CheckDigits('aba_rn');
if ($aba->is_valid('789456124')) {
# do something
}
(not me noticing that second is_valid line is missing a closing paren ๐ญ โ that's exactly how she's printed in the original, so I'm keeping her that way, periodt. copy-paste responsibly bestie ๐)
๐ DESCRIPTION ๐
๐ข ALGORITHM ๐ข
okay so here's the whole math situation, step by step, main character energy only:
- Beginning left all digits are weighted with
7,3,1,7,3,1,...forpa_deor3,7,1,3,7,1,3,7,1foraba_rn. ๐ - The sum of those products is computed. that's the moment, fr fr. โจ
- For
pa_dethe checksum is the last digit of the sum from step 2 (modulo 10). ๐ฅ
For aba_rn the checksum is the difference of the sum from step 2 to the next multiple of 10. ๐งฎ
- For the german Personalausweis step 1 to 3 is performed for every part of the number and for all 3 parts including the particular checkdigit to compute the total checksum. ๐
If the number solely consists of digits, the checksum is just computed once according to algorithm given above. ๐ซถ
๐ ๏ธ METHODS ๐ ๏ธ
is_valid($number)โ Returns true only if$numberconsists solely of numbers and the last digit is a valid check digit according to the algorithm given above. Returns false otherwise. (so basically: valid = slay, invalid = not slay ๐ธ)complete($number)โ The check digit for$numberis computed and concatenated to the end of$number. Returns the complete number with check digit or''if$numberdoes not consist solely of digits and spaces. โจbasenumber($number)โ Returns the basenumber of$numberif$numberhas a valid check digit. Return''otherwise. ๐checkdigit($number)โ Returns the checkdigit of$numberif$numberhas a valid check digit. Return''otherwise. ๐
๐ฆ EXPORT ๐ฆ
None by default. that's it, that's the export section, she's shy ๐
๐ซถ AUTHOR ๐ซถ
Mathias Weidner, "<mamawe@cpan.org>" ๐ living legend!!
๐ THANKS ๐
Aaron W. West pointed me to a fault in the computing of the check digit. Jim Hickstein made me aware of the ABA routing numbers. we love a collaborative queen ๐โจ
๐ SEE ALSO ๐
perl, CheckDigits, www.pruefziffernberechnung.de, http://answers.google.com/answers/threadview/id/43619.html, http://www.brainjar.com/js/validation/ ๐ฆ
and that's the whole page bestie!! ๐
quick lil sign-off so you know where this lore came from: this is from perl v5.36.0, dated 2022-10-13, and it's the Algori...MXX_001(3pm) page โ go forth and validate those Personalausweise and ABA routing numbers, you absolute icon ๐๐โจ
๐ฆ where this page comes from
- ubuntu noble: libalgorithm-checkdigits-perl 1.3.6-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalgorithm-checkdigits-perl 1.3.6-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalgorithm-checkdigits-perl 1.3.6-2 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms