Algori...M97_002(3pm)

๐Ÿ“ฆ
version 1.3.6 ยท 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

CheckDigits::M97_002 โ€” the lil module that computes check digits for the International Bank Account Number (aka IBAN) ๐Ÿฆโœจ

It lives in the Algori...M97_002(3pm) manual, and it is genuinely iconic, no cap.


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

use Algorithm::CheckDigits;

$iban = CheckDigits('iban');

if ($iban->is_valid('DE88 2008 0000 09703 7570 0')) {
      # do something
}

$cn = $iban->complete('DE00 2008 0000 09703 7570 0');
# $cn = 'DE88 2008 0000 09703 7570 0'

$cd = $iban->checkdigit('DE88 2008 0000 09703 7570 0');
# $cd = '88'

$bn = $iban->basenumber('DE88 2008 0000 09703 7570 0');
# $bn = 'DE00 2008 0000 09703 7570 0'

Bestie, look at that. She validates, she completes, she checkdigits, she basenumbers. Versatile queen ๐Ÿ‘‘๐Ÿ’…


โœจ DESCRIPTION โœจ

๐Ÿงฎ ALGORITHM ๐Ÿงฎ

Okay so here's the little routine, step by step. Pay attention, it's giving math but make it cute โœจ

  1. First we gotta prep the IBAN number. The first two letters and the checksum get moved all the way to the right end. Then every letter gets substituted according to the substitute table ๐ŸŒธ, and the checksum is set to '00'.
  2. Take the whole number, hit it with modulo 97.
  3. The checksum is the difference between 98 and whatever step 1 handed you.
  4. If the checksum is smaller than 10, a leading zero gets prepended. (Cute lil zero for padding, obsessed ๐ŸŽ€)

๐Ÿ› ๏ธ METHODS ๐Ÿ› ๏ธ

  • is_valid($number) โ€” Returns true only if $number consists solely of numbers AND the last digit is a valid check digit according to the algorithm above. Returns false otherwise. She's picky and honestly? deserved ๐Ÿ’…
  • complete($number) โ€” The check digit for $number gets computed and concatenated onto the end of $number. Returns the complete number with check digit, or '' if $number doesn't consist solely of digits and spaces.
  • basenumber($number) โ€” Returns the basenumber of $number if $number has a valid check digit. Returns '' otherwise.
  • checkdigit($number) โ€” Returns the checkdigits of $number if $number has a valid check digit. Returns '' otherwise.

๐Ÿ“ฆ EXPORT ๐Ÿ“ฆ

None by default. She's low maintenance like that ๐Ÿ™ˆ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Mathias Weidner, "<mamawe@cpan.org>" โ€” absolute legend, fr fr ๐Ÿซถ


๐ŸŒŸ THANKS ๐ŸŒŸ

Detlef Pilzecker pointed out to me that there may be more letters as the first two in an IBAN number. He also made me aware of a faster method to compute the check number than using Math::BigInt. King behavior honestly ๐Ÿงšโœจ


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

  • perl
  • CheckDigits
  • www.pruefziffernberechnung.de
  • www.sic.ch/en/tkicch_home/tkicch_standardization/tkicch_financialinstitutions_ibanipi.htm

๐Ÿ’€ Friendly reminder bestie: check digits are serious business, so always feed is_valid a string that actually fits the rules before you trust it with your whole banking vibe.

And that's the whole page, periodt ๐Ÿ’–. This one shipped with perl v5.36.0 and got dated 2022-10-13, wrapped up in the Algori...M97_002(3pm) manual โ€” so if you ever forget where you read this masterpiece, iykyk ๐ŸŽ€โญ

๐Ÿ“ฆ where this page comes from