Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

CRC-ITU checksum function

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

CRC-ITU checksum function

Postby chowdotya » Sun Jan 23, 2011 8:48 pm

If you have trouble with CRC-ITU checksum, you can use this PHP function:
Code: Select all
function crcx25($data) {
   $content = explode(' ',$data) ;
   $len = count($content) ;
   $n = 0 ;
   
   $crc = 0xFFFF;   
   while ($len > 0)
   {
      $crc ^= hexdec($content[$n]) ;
      for ($i=0; $i<8; $i++) {
         if ($crc & 1) $crc = ($crc >> 1) ^ 0x8408;
         else $crc >>= 1;
      }
      $n++ ;
      $len-- ;
   }
   
   return(~$crc);
}

Note:
1. example of $data format :
Code: Select all
$data = '05 30 45 85'
2. it will return decimal value.
chowdotya
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Jan 23, 2011 7:39 pm

Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.