PHP Classes

File: qcp64.class.php

Recommend this page to a friend!
  Classes of Simon Roberts   QCP64 CRC   qcp64.class.php   Download  
File: qcp64.class.php
Role: Class source
Content type: text/plain
Description: QCP64 Base Class
Class: QCP64 CRC
Compute checksum of variable length data
Author: By
Last change: Final Version 1.6.4
Date: 16 years ago
Size: 3,093 bytes
 

Contents

Class file image Download
<?
// $Id: qcp64.class.php 1.6.4 2008-08-15 13:40:00 (final) wishcraft $
// ------------------------------------------------------------------------ //
// CLORA - Chronolabs Australia //
// Copyright (c) 2008 //
// <http://www.chronolabs.org.au/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the SDPL Source Directive Public Licence //
// as published by Chronolabs Australia; either version 2 of the License, //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Chronolab Australia //
// Chronolabs International PO BOX 699, DULWICH HILL, NSW, 2203, Australia //
// ------------------------------------------------------------------------ //

if (!class_exists('qcp64'))
{

   
    class
qcp64
   
{
        var
$base;
        var
$enum;
        var
$seed;
        var
$crc;
           
        function
__construct($data, $seed, $len=29)
        {
           
$this->seed = $seed;
           
$this->length = $len;
           
$this->base = new qcp64_base((int)$seed);
           
$this->enum = new qcp64_enumerator($this->base);
           
            if (!empty(
$data))
            {
                for (
$i=1; $i<strlen($data); $i++)
                {
                   
$enum_calc = $this->enum->enum_calc(substr($data,$i,1),$enum_calc);
                }
               
$qcp64_crc = new qcp64_leaver($enum_calc, $this->base, $this->length);
               
$qcp64_crc->reset_leaver();
               
$this->crc = $qcp64_crc->crc;
            }
           
        }
           
        function
calc($data)
        {
            for (
$i=1; $i<strlen($data); $i++)
            {
               
$enum_calc = $this->enum->enum_calc(substr($data,$i,1),$enum_calc);
            }
           
$qcp64_crc = new qcp64_leaver($enum_calc, $this->base, $this->length);
           
$qcp64_crc->reset_leaver();
            return
$qcp64_crc->crc;
        }
       
    }
}

require (
'qcp64.base.php');
require (
'qcp64.enumerator.php');
require (
'qcp64.leaver.php');