def luhn_checksum_is_valid(self, number):

        sum = 0
        num_digits = len(number)
        oddeven = num_digits & 1

        for count in range(0, num_digits):
            digit = int(number[count])

            if not (( count & 1 ) ^ oddeven ):
                digit = digit * 2
            if digit > 9:
                digit = digit - 9

            sum = sum + digit

        return ( (sum % 10) == 0 )
Checks to make sure that the SIN passes a luhn mod-10 checksum
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/contrib/localflavor/ca/forms.py/CASocialInsuranceNumberField.luhn_checksum_is_valid