Newsgroups: can.general
Path: utzoo!utgpu!jarvis.csri.toronto.edu!csri.toronto.edu!erlebach
From: erlebach@csri.toronto.edu (Beverly Erlebacher)
Subject: Re: SIN Number
Message-ID: <8812230029.AA13931@bloor.csri.toronto.edu>
Summary: correct algorithm
Keywords: Checksum Procedure
Organization: University of Toronto, CSRI
References: <302@idacom.UUCP> <723@apss.apss.ab.ca> <1902@pembina.UUCP> <420@perle.UUCP> <4367@hcr.UUCP>
Distribution: can
Date: Thu, 22 Dec 88 19:29:00 EST


I needed to validate SINs for an employee benefits system I wrote some
years ago.  I phoned Employment and Immigration and they mailed me the
specs on the SIN check digit scheme.  I don't know where I've put that
document, but I can extract the algorithm from my code.  The comments
seem to preserve some of the original wording.

1.  Sum the odd-ordered digits except the 9th. (1st, 3rd, 5th, 7th digits)

2.  For each even-ordered digit (2nd, 4th, 6th, 8th), double the digit, 
    and add together the digits of the result.  Then sum these results.

3.  Add the totals from steps 1 and 2.  Subtract the sum from the next
    larger multiple of 10.  The result is the check digit - it should
    match the ninth digit of the SIN.

For example:  validate the SIN 123-789-456

1.  1 + 3 + 8 + 4 = 16

2.  2 + 2 = 4
    7 + 7 = 14 -> 5
    9 + 9 = 18 -> 9
    5 + 5 = 10 -> 1

    4 + 5 + 9 + 1 = 19

3.  16 + 19 = 35
    40 - 35 = 5

    Since 5 does not equal 6, this is not a valid SIN (surprise!).

This is an ordinary simple check digit scheme. It is intended to detect
the most common keying errors (1-digit errors and the transposition of
adjacent digits), rather than to catch intentionally bogus numbers.

--------
Beverly Erlebacher				erlebach@turing.toronto.edu
Proceeds of this posting to the Society for Rehabilitation of RPG Programmers


