I programmed this for PHP, but now it seems we need an offline version, which I would prefer in C, as it is extremely simple, yet I cannot program in C. it would be console (dos) based, and requesting an input for only $trail, $security being 12963. the security # is not really a security number like you would think, it's just a reference number for our systems. my php code is as follows:
<?
/*****************************************************
Filename: [login to view URL]
Function: Generate check digit number for Canada
Customs transaction numbers
Writer: Ryan Forsyth
Date: 06/27/06
*****************************************************/
Function Transaction($security="", $trail="", $reference="") {
//Turn sections into 13 digit reference Number
$transaction = $security.$trail.$reference;
//Split transaction into seperate digits in an array
$split = preg_split('//', $transaction, -1, PREG_SPLIT_NO_EMPTY);
//Starting value for check digit
$sum = 0;
//Used to ensure calculation is even/odd/even/etc
$multiplier = 0;
//Start checking in array for values
foreach ($split as $value) {
//If multiplier is an even number, do this
if(($multiplier - (2 * floor($multiplier/2))) == 0) {
//multiply by 1 to get the even sum
$numb = ($value * 1);
//Check to make sure number is 10 or under. If over, add the first digit
//to the second digit until end number is single digit
while($numb >= 10) {
$split_numb = preg_split('//', $numb, -1, PREG_SPLIT_NO_EMPTY);
$numb = ($split_numb[0] + $split_numb[1]);
}
//add value to sum
$sum = $numb + $sum;
}
//If multiplier is an odd number, do this
else {
//multiply by 2 to get the odd sum
$numb = ($value * 2);
//Check to make sure number is 10 or under. If over, add the first digit
//to the second digit until end number is single digit
while($numb >= 10) {
$split_numb = preg_split('//', $numb, -1, PREG_SPLIT_NO_EMPTY);
$numb = ($split_numb[0] + $split_numb[1]);
}
//add value to sum
$sum = $numb + $sum;
}
//Add 1 to multiplier to switch between even and odd
$multiplier++;
}
//Divide sum by 10 to get a quotient and a remainder
$sum = $sum/10;
//Split quotient and remainder into an array
$sum = explode(".", $sum);
//Output the remainder as check digit for the reference number
return $sum[1];
}
?>
Hello, I am an experienced, Ontario-based C programmer. I can port your code into C easily. The only additional information I would need from you would be a set of 5 numbers and associated checksums so that the module could be tested.
hi
my team is expert in c/c++ so your work will be done professionals the work can be completed in less days if you say
your work will be done in a priority way
looking forward for the work
regards
team weboweb