Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate a Singaporean FIN?

Can anyone provide an algorithm to validate a Singaporean FIN?

I know with a Singaporean NRIC I can validate it via modulo 11 and then compare the result to a lookup table but cannot find a similar lookup table for the FIN.

I also do not know for sure if the modulo 11 is the correct method to validate.

I am aware the government sells a algorithm for $400 but maybe someone knows a cheaper way.

Bonus points for c# implementation.

like image 370
mjallday Avatar asked Mar 10 '09 10:03

mjallday


People also ask

What is the new Foreign Identification Number (FIN) for Singapore?

From January 1, 2022, the Immigration & Checkpoints Authority (ICA) will issue a new Foreign Identification Number (FIN) series with the prefix M. Foreigners working, studying, or staying in Singapore are given FINs, which are unique identification numbers provided by the ICA and other government agencies.

What is a fin number?

For the purposes of identification and registration, each person working, studying, or residing in Singapore is given a unique identity number Usage of FIN? FINs are personal to each person and cannot be transferred to other foreigners after the pass holders have left Singapore permanently or passed away.

Is my re entry permit valid in Singapore?

Check Re-Entry Permit Validity Ensure that you have a valid Re-Entry Permit (REP). A valid REP is necessary whenever a Singapore permanent resident (PR) wishes to travel out of Singapore. It enables a PR to retain his/her PR status while away from Singapore.

How to check if a tenant is legit in Singapore?

Ensure that the prospective tenant is in Singapore legitimately. How to check work pass card. You should personally inspect the original Work Permit, Employment Pass or S Pass card by doing the following: ... Work pass number for Work Permit or S Pass holders; Check that the pass card matches the design of the MOM issued passes.


1 Answers

And again in PHP

function isNricValid ($theNric) {

    $multiples = array( 2, 7, 6, 5, 4, 3, 2 );

    if (!$theNric || $theNric == '')
    {
        return false;
    }

    if (strlen($theNric) != 9)
    {
        return false;
    }

    $total = 0;
    $count = 0;
    $numericNric = 0;

    $first = $theNric[0];
    $last = $theNric[strlen($theNric) - 1];

    if ($first != 'S' && $first != 'T')
    {
        return false;
    }

    $numericNric = substr($theNric, 1, strlen($theNric) - 2);

    if (!is_numeric ($numericNric)) {
        return false;
    }

    while ($numericNric != 0)
    {
        $total += ($numericNric % 10) * $multiples[sizeof($multiples) - (1 + $count++)];

        $numericNric /= 10;
        $numericNric = floor($numericNric);
    }

    $outputs = '';
    if (strcmp($first, "S") == 0)
    {
        $outputs = array( 'J', 'Z', 'I', 'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A' );
    }
    else
    {   
        $outputs = array( 'G', 'F', 'E', 'D', 'C', 'B', 'A', 'J', 'Z', 'I', 'H' );
    }

    return $last == $outputs[$total % 11];

}

function isFinValid ($fin)
{
    $multiples = array( 2, 7, 6, 5, 4, 3, 2 );
    if (!$fin || $fin == '')
    {
        return false;
    }

    if (strlen($fin) != 9)
    {
        return false;
    }

    $total = 0;
    $count = 0;
    $numericNric = 0;
    $first = $fin[0];
    $last = $fin[strlen($fin) - 1];

    if ($first != 'F' && $first != 'G')
    {
        return false;
    }

    $numericNric = substr($fin, 1, strlen($fin) - 2);

    if (!is_numeric ($numericNric)) {
        return false;
    }

    while ($numericNric != 0)
    {
        $total += ($numericNric % 10) * $multiples[sizeof($multiples) - (1 + $count++)];

        $numericNric /= 10;
        $numericNric = floor($numericNric);
    }

    $outputs = array();

    if (strcmp($first, 'F') == 0)
    {
        $outputs = array( 'X', 'W', 'U', 'T', 'R', 'Q', 'P', 'N', 'M', 'L', 'K' );
    }
    else
    {
        $outputs = array( 'R', 'Q', 'P', 'N', 'M', 'L', 'K', 'X', 'W', 'U', 'T' );
    }

    return $last == $outputs[$total % 11];
}
like image 148
mjallday Avatar answered Nov 09 '22 11:11

mjallday