jonelo.jacksum.algorithm

Class CrcGeneric


public class CrcGeneric
extends AbstractChecksum

Jacksum version 1.7.0 - checksum utility in Java Copyright (C) 2001-2006 Dipl.-Inf. (FH) Johann Nepomuk Loefflmann, All Rights Reserved, http://www.jonelo.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. E-mail: jonelo@jonelo.de

Constructor Summary

CrcGeneric(String props)
Constructor with a String parameter
CrcGeneric(int width, long poly, long initialValue, boolean refIn, boolean refOut, long xorOut)
Constructor with all parameters as defined in the Rocksoft^tm Model CRC Algorithm

Method Summary

byte[]
getByteArray()
Returns the result of the computation as byte array
long
getInitialValue()
Get the initial register value
String
getName()
Get the name of the algorithm
long
getPoly()
Get the algorithm's polynomial
boolean
getRefIn()
Should input bytes be reflected?
boolean
getRefOut()
Get whether the output CRC should be reflected
String
getString()
The toString() method is derived from the AbstractChecksum
long
getValue()
Returns the value of the checksum
int
getWidth()
Get the width in bits
long
getXorOut()
Get the XOR parameter
void
reset()
Resets the checksum object to its initial values for further use
void
setInitialValue(long initialValue)
Set the initial register value
void
setPoly(long poly)
Set the algorithm's polynomial
void
setRefIn(boolean refIn)
Reflect input bytes?
void
setRefOut(boolean refOut)
Set whether the output CRC should be reflected
void
setWidth(int width)
Set the width in bits
void
setXorOut(long xorOut)
Set the XOR parameter
void
update(byte b)
Updates the checksum with the specified byte
void
update(int b)
Updates the checksum with the specified byte

Constructor Details

CrcGeneric

public CrcGeneric(String props)
            throws NoSuchAlgorithmException
Constructor with a String parameter
Parameters:
props - All parameters as defined in the Rocksoft^tm Model CRC Algorithm separated by a comma Example: crc:32,04C11DB7,FFFFFFFF,true,true,FFFFFFFF

CrcGeneric

public CrcGeneric(int width,
                  long poly,
                  long initialValue,
                  boolean refIn,
                  boolean refOut,
                  long xorOut)
            throws NoSuchAlgorithmException
Constructor with all parameters as defined in the Rocksoft^tm Model CRC Algorithm
Parameters:
width - the width of the value in bits
poly - The algorithm's polynomial (without the highest bit)
initialValue - the initial register value
refIn - Reflect input bytes?
refOut - Reflect output CRC?
xorOut - XOR this to output CRC

Method Details

getByteArray

public byte[] getByteArray()
Returns the result of the computation as byte array
Returns:
the result of the computation as byte array

getInitialValue

public long getInitialValue()
Get the initial register value
Returns:
the initial register value

getName

public String getName()
Get the name of the algorithm
Returns:
the name of the algorithm as String

getPoly

public long getPoly()
Get the algorithm's polynomial
Returns:
the algorithm's polynomial

getRefIn

public boolean getRefIn()
Should input bytes be reflected?
Returns:
should input bytes be reflected?

getRefOut

public boolean getRefOut()
Get whether the output CRC should be reflected
Returns:
should the output CRC be reflected?

getString

public String getString()
The toString() method is derived from the AbstractChecksum
Returns:
a String which is understood by the constructor

getValue

public long getValue()
Returns the value of the checksum
Returns:
the value of the checksum

getWidth

public int getWidth()
Get the width in bits
Returns:
the width in bits

getXorOut

public long getXorOut()
Get the XOR parameter
Returns:
the XOR parameter

reset

public void reset()
Resets the checksum object to its initial values for further use

setInitialValue

public void setInitialValue(long initialValue)
Set the initial register value
Parameters:
initialValue - the initial register value

setPoly

public void setPoly(long poly)
Set the algorithm's polynomial
Parameters:
poly - the algorithm's polynomial

setRefIn

public void setRefIn(boolean refIn)
Reflect input bytes?
Parameters:
refIn - reflect input bytes?

setRefOut

public void setRefOut(boolean refOut)
Set whether the output CRC should be reflected
Parameters:
refOut - should the output CRC be reflected?

setWidth

public void setWidth(int width)
Set the width in bits
Parameters:
width - the width in bits

setXorOut

public void setXorOut(long xorOut)
Set the XOR parameter
Parameters:
xorOut - the XOR parameter

update

public void update(byte b)
Updates the checksum with the specified byte
Parameters:
b - the byte

update

public void update(int b)
Updates the checksum with the specified byte
Parameters:
b - the byte