Collections:
Other Resources:
ISIN Checksum Algorithm
What is the ISIN Checksum Algorithm?
✍: FYIcenter.com
The ISIN Checksum Algorithm is called
the Luhn algorithm with "Modulus 10 Double Add Double" technique.
Based on 2 examples given on wikipedia.com, the ISIN Checksum Algorithm can be described in pseudo code as follows:
algorithm Isin-Check-Digit is
input: isin, a 11-character ISIN.
isin_num := ""
for 0 ≤ i < 11 do
c := the ith character of isin
if c is a digit then
isin_num := append c to the end
else if c is a letter then
p := ordinal position of c in the alphabet (A=1, B=2...)
v := p + 9
isin_num := append v to the end
end if
repeat
sum := 0
n: = number digites in isin_num
for 0 ≤ i < n do
d := pop out the last digit of isin_num
if i is even then
d := d × 2
end if
sum := sum + int(v div 10) + v mod 10
repeat
return (10 - (sum mod 10)) mod 10
Here is a Python version of the above pseudo code published on stackoverflow.com.
import string
isin = 'US4581401001'
def digit_sum(n):
return (n // 10) + (n % 10)
alphabet = {letter: value for (value, letter) in
enumerate(''.join(str(n) for n in range(10)) + string.ascii_uppercase)}
isin_to_digits = ''.join(str(d) for d in (alphabet[v] for v in isin[:-1]))
isin_sum = 0
for (i, c) in enumerate(reversed(isin_to_digits), 1):
if i % 2 == 1:
isin_sum += digit_sum(2*int(c))
else:
isin_sum += int(c)
checksum_digit = abs(- isin_sum % 10)
Here is a PHP version of the above pseudo code modified from the "isin" PHP library by David Marland on GitHub.
function isin_checksum($input) {
$characters = str_split($input);
// convert all characters to numbers (ints)
foreach ($characters as $i => $char) {
// cast to int, by using intval at base 36 we also convert letters to numbers
$characters[$i] = intval($char, 36);
}
// pull out the checkDigit
$checkDigit = array_pop($characters);
// put the string back together
$number = implode('', $characters);
// performs the Luhn algorithm
// to obtain a check digit
// first split up the string
$numbers = str_split($number);
// calculate the positional value.
// when there is an even number of digits the second group will be multiplied, so p starts on 0
// when there is an odd number of digits the first group will be multiplied, so p starts on 1
$p = count($numbers) % 2;
// run through each number
foreach ($numbers as $i => $num) {
$num = (int) $num;
// every positional number needs to be multiplied by 2
if ($p % 2) {
$num = $num*2;
// if the result was more than 9
// add the individual digits
$num = array_sum(str_split($num));
}
$numbers[$i] = $num;
$p++;
}
// get the total value of all the digits
$sum = array_sum($numbers);
// get the remainder when dividing by 10
$mod = $sum % 10;
// subtract from 10
$rem = 10 - $mod;
// mod from 10 to catch if the result was 0
$digit = $rem % 10;
return $digit;
}
2025-11-06, ∼893🔥, 0💬
Popular Posts:
If you know the CUSIP of a US Treasury security, you can lookup its issuing information with our sea...
If you know the CUSIP of a US Treasury security, you can lookup its issuing information with our sea...
What are Historical Values of the US Unadjusted YoY (Year over Year) Inflation Rates? Here are Histo...
What is the CBOE Volatility Index (Cboe Indices: ^VIX) index? What are the historical values of the ...
What are Historical Values of the US Seasonally Adjusted MoM (Month over Month) Inflation Rates? Her...