eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CRCStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: CRCStream


Inheritance:

   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

Description:


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

copyright

COPYRIGHT (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.

Class protocol:

initialization
o  crcTableFor: generatorPolynomInteger
construct the polynom-specific lookup table

Usage example(s):

CRC8Stream crcTableFor:(16r1D bitReversed8)

o  flushCrcTables
CRC16Stream flushCrcTables
CRC32Stream flushCrcTables

instance creation
o  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

o  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

o  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


Instance protocol:

accessing
o  generatorPolynom
answer the generator polynom (LSB)

o  initValue
answer the init value

o  xorOut
answer the xorOut value

initialization
o  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

o  reset
reset the current crc value

queries
o  hashValue
return the computed CRC

writing
o  nextPutBytes: count from: anObject startingAt: start
add the hash of anObject to the computed hash so far.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:42:35 GMT