|
Class: CRC8Stream
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
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:]
SHA1Stream
MD5Stream
instance creation
-
generatorPolynomMSB: anInteger
-
notice, in literature, the generator polynom is usually specified as an MSB number
-
generatorPolynomMSB: anInteger initValue: initValue
-
notice, in literature, the generator polynom is usually specified as an MSB number
-
generatorPolynomMSB: anInteger initValue: initValueArg xorOut: xorOut
-
notice, in literature, the generator polynom is usually specified as an MSB number
-
newSAE_J1850
-
return an instance of the SAE_J1850 CRC8 (used in AUTOSAR)
-
new_2F
-
return an instance of the CRC8-2F (used in AUTOSAR).
Currently broken.
queries
-
hashSize
-
return the size of the hashvalue returned by instances of this class (in bytes)
initialization
-
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
-
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
-
hashValue
-
return the computed CRC
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'
|
|