|
Class: CRCStream
Object
|
+--Stream
|
+--HashStream
|
+--CRCStream
|
+--CRC16Stream
|
+--CRC32Stream
|
+--CRC8Stream
- Package:
- stx:libbasic2
- Category:
- System-Crypt-Hashing
- Version:
- rev:
1.16
date: 2024/01/08 15:58:31
- user: cg
- file: CRCStream.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
abstract superclass of crc streams;
refactored from original crc32 stream.
For details, see https://en.wikipedia.org/wiki/Cyclic_redundancy_check
Only use CRC to protect against communication errors;
DO NOT use CRC for cryptography, authentication, security, etc.
- use secure hashes for those instead.
[parameters:]
polynomials:
CRC_POLY_16 0xA001
CRC_POLY_32 0xEDB88320L
CRC_POLY_CCITT 0x1021
CRC_POLY_DNP 0xA6BC
CRC_POLY_KERMIT 0x8408
start values:
CRC_START_8 0x00
CRC_START_16 0x0000
CRC_START_MODBUS 0xFFFF
CRC_START_XMODEM 0x0000
CRC_START_CCITT_1D0F 0x1D0F
CRC_START_CCITT_FFFF 0xFFFF
CRC_START_KERMIT 0x0000
CRC_START_SICK 0x0000
CRC_START_DNP 0x0000
CRC_START_32 0xFFFFFFFF
copyrightCOPYRIGHT (c) 2018 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
initialization
-
crcTableFor: generatorPolynomInteger
-
construct the polynom-specific lookup table
Usage example(s):
CRC8Stream crcTableFor:(16r1D bitReversed8)
|
-
flushCrcTables
-
CRC16Stream flushCrcTables
CRC32Stream flushCrcTables
instance creation
-
generatorPolynom: anLSBInteger
-
notice, in literature, the generator polynom is usually specified as an MSB number
Usage example(s):
self assert:((self generatorPolynom:16r82F63B78)
nextPut:'123456789';
hashValue) = 16rE3069283
|
-
generatorPolynom: anLSBInteger initValue: initValue
-
notice, in literature, the generator polynom is usually specified as an MSB number
Usage example(s):
self assert:((self generatorPolynom:16r82F63B78)
nextPut:'123456789';
hashValue) = 16rE3069283
|
-
generatorPolynom: anLSBInteger initValue: initValue xorOut: xorOut
-
notice, in literature, the generator polynom is usually specified as an MSB number
Usage example(s):
self assert:((self generatorPolynom:16r82F63B78)
nextPut:'123456789';
hashValue) = 16rE3069283
|
accessing
-
generatorPolynom
-
answer the generator polynom (LSB)
-
initValue
-
answer the init value
-
xorOut
-
answer the xorOut value
initialization
-
generatorPolynom: polyLSB initValue: initValueArg xorOut: xorOutArg
-
set the generator polynom for this instance.
And set start and xorOut.
Computes the crcTable for this polynom.
Notice the bit order is LSB
-
reset
-
reset the current crc value
queries
-
hashValue
-
return the computed CRC
writing
-
nextPutBytes: count from: anObject startingAt: start
-
add the hash of anObject to the computed hash so far.
|