Example #1
0
function iban_verify_checksum($iban)
{
    # convert to machine format
    $iban = iban_to_machine_format($iban);
    # move first 4 chars (countrycode and checksum) to the end of the string
    $tempiban = substr($iban, 4) . substr($iban, 0, 4);
    # subsitutute chars
    $tempiban = iban_checksum_string_replace($tempiban);
    # mod97-10
    $result = iban_mod97_10($tempiban);
    # checkvalue of 1 indicates correct IBAN checksum
    if ($result != 1) {
        return false;
    }
    return true;
}
Example #2
0
function iban_find_checksum($iban)
{
    $iban = iban_to_machine_format($iban);
    # move first 4 chars to right
    $left = substr($iban, 0, 2) . '00';
    # but set right-most 2 (checksum) to '00'
    $right = substr($iban, 4);
    # glue back together
    $tmp = $right . $left;
    # convert letters using conversion table
    $tmp = iban_checksum_string_replace($tmp);
    # get mod97-10 output
    $checksum = iban_mod97_10($tmp);
    return str_pad(98 - $checksum, 2, '0', STR_PAD_LEFT);
}