Package ru.soniir.crccalc
Class AlgoParams
- java.lang.Object
-
- ru.soniir.crccalc.AlgoParams
-
public class AlgoParams extends java.lang.ObjectRepresentation CRC algorithm parameters Created by anthony on 11.05.2017.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]testBytes
-
Constructor Summary
Constructors Constructor Description AlgoParams(java.lang.String name, int hashSize, long poly, long init, boolean refIn, boolean refOut, long xorOut, long check)Create new CRC algorithm
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)longgetCheck()This field is not strictly part of the definition, and, in the event of an inconsistency between this field and the other field, the other fields take precedence.This field is a check value that can be used as a weak validator of implementations of the algorithm.The field contains the checksum obtained when the ASCII string "123456789" is fed through the specified algorithm (i.e. 313233...intgetHashSize()This is hash size.longgetInit()This parameter specifies the initial value of the register when the algorithm starts.This is the value that is to be assigned to the register in the direct table algorithm.java.lang.StringgetName()This is a name given to the algorithm.longgetPoly()This parameter is the poly.longgetXorOut()This is an W-bit value that should be specified as a hexadecimal number.It is XORed to the final register value (after the REFOUT) stage before the value is returned as the official checksum.inthashCode()booleanisRefIn()This is a boolean parameter.booleanisRefOut()This is a boolean parameter.
-
-
-
Constructor Detail
-
AlgoParams
public AlgoParams(java.lang.String name, int hashSize, long poly, long init, boolean refIn, boolean refOut, long xorOut, long check)Create new CRC algorithm- Parameters:
name- CRC algorithm namehashSize- hash sizepoly- poly numberinit- initial value of the CRC algorithmrefIn- input bytes are processedrefOut- final register value is reflected firstxorOut- value is XORed to the final register valuecheck- CRC value for new byte[]{'1','2','3','4','5','6','7','8','9'}
-
-
Method Detail
-
getName
public java.lang.String getName()
This is a name given to the algorithm. A string value.- Returns:
- CRC algorithm name
-
getHashSize
public int getHashSize()
This is hash size.- Returns:
- hash size
-
getPoly
public long getPoly()
This parameter is the poly. This is a binary value that should be specified as a hexadecimal number.The top bit of the poly should be omitted.For example, if the poly is 10110, you should specify 06. An important aspect of this parameter is that it represents the unreflected poly; the bottom bit of this parameter is always the LSB of the divisor during the division regardless of whether the algorithm being modelled is reflected.- Returns:
- poly number
-
getInit
public long getInit()
This parameter specifies the initial value of the register when the algorithm starts.This is the value that is to be assigned to the register in the direct table algorithm. In the table algorithm, we may think of the register always commencing with the value zero, and this value being XORed into the register after the N'th bit iteration. This parameter should be specified as a hexadecimal number.- Returns:
- initial value of the CRC algorithm
-
isRefIn
public boolean isRefIn()
This is a boolean parameter. If it is TRUE, input bytes are processed with bit 7 being treated as the most significant bit (MSB) and bit 0 being treated as the least significant bit.If this parameter is FALSE, each byte is reflected before being processed.- Returns:
- input bytes are processed
-
isRefOut
public boolean isRefOut()
This is a boolean parameter. If it is set to FALSE, the final value in the register is fed into the XOROUT stage directly, otherwise, if this parameter is TRUE, the final register value is reflected first.- Returns:
- final register value is reflected first
-
getXorOut
public long getXorOut()
This is an W-bit value that should be specified as a hexadecimal number.It is XORed to the final register value (after the REFOUT) stage before the value is returned as the official checksum.- Returns:
- value is XORed to the final register value
-
getCheck
public long getCheck()
This field is not strictly part of the definition, and, in the event of an inconsistency between this field and the other field, the other fields take precedence.This field is a check value that can be used as a weak validator of implementations of the algorithm.The field contains the checksum obtained when the ASCII string "123456789" is fed through the specified algorithm (i.e. 313233... (hexadecimal)).- Returns:
- CRC value for new byte[]{'1','2','3','4','5','6','7','8','9'}
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-