eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CRC8Stream':

Home

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

Class: CRC8Stream


Inheritance:

   Object
   |
   +--Stream
      |
      +--HashStream
         |
         +--CRCStream
            |
            +--CRC8Stream

Package:
stx:libbasic2
Category:
System-Crypt-Hashing
Version:
rev: 1.2 date: 2019/03/25 13:33:39
user: cg
file: CRC8Stream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


ATTENTION: CRC8Stream is currently BROKEN (in development)

newSAE_J1850:
  Standard CRC method as defined by SAE J1850 (used in AUTOSAR)
  The polynomial is 0x1D; initial value 0xFF; xorOut is 0xFF
  

[instance variables:]

[class variables:]


Related information:

    SHA1Stream
    MD5Stream

Class protocol:

instance creation
o  generatorPolynomMSB: anInteger
notice, in literature, the generator polynom is usually specified as an MSB number

o  generatorPolynomMSB: anInteger initValue: initValue
notice, in literature, the generator polynom is usually specified as an MSB number

o  generatorPolynomMSB: anInteger initValue: initValueArg xorOut: xorOut
notice, in literature, the generator polynom is usually specified as an MSB number

o  newSAE_J1850
return an instance of the SAE_J1850 CRC8 (used in AUTOSAR)

o  new_2F
return an instance of the CRC8-2F (used in AUTOSAR).
Currently broken.

queries
o  hashSize
return the size of the hashvalue returned by instances of this class (in bytes)


Instance protocol:

initialization
o  generatorPolynom: anLSBInteger
set the generator polynom for this instance,
set start and xorOut to 16rFF.
Note: you have to set the bit-reversed value, so the LSB must be first

o  generatorPolynom: anLSBInteger initValue: initValueArg
set the generator polynom for this instance.
set start to initValueArg and xorOut to 16rFF.
Note: you have to set the bit-reversed value, so the LSB must be first

queries
o  hashValue
return the computed CRC


Examples:


expect xxx:
  self information:(CRC8Stream new hashValueOf:'resume') hexPrintString
expect xxx:
  self information:(CRC16Stream new
                          nextPut:$r;
                          nextPut:$e;
                          nextPut:$s;
                          nextPut:$u;
                          nextPut:$m;
                          nextPut:$e;
                          hashValue) hexPrintString
expect xxx:
  self information:(CRC16Stream hashValueOf:#[1 2 3 4 5 6 7]) hexPrintString
expect xxx:
  self information:((CRC16Stream hashValueOf:#[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
           16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
           16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
           16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]) hexPrintString)
expect xxx: timing throughput:
  |hashStream n t|

  hashStream := CRC16Stream new.
  n := 1000000.
  t := Time millisecondsToRun:[
          n timesRepeat:[
              hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
          ].
       ].
  t := (t / 1000) asFloat.
  Transcript show:'crc16:'; showCR: hashStream hashValue hexPrintString.
  Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'.
  Transcript show:(n*50/1024 / t); showCR:' Kb/s'


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 19 Sep 2019 15:27:41 GMT