CRC16Stream.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Jun 2019 14:28:51 +0200
changeset 5050 44fa8672d102
parent 4918 fbda05fa45dc
permissions -rw-r--r--
#DOCUMENTATION by cg class: SharedQueue comment/format in: #next #nextWithTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4858
8ba5358392d2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4848
diff changeset
     1
"{ Encoding: utf8 }"
8ba5358392d2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4848
diff changeset
     2
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2003 by eXept Software AG
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	      All Rights Reserved
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
"{ NameSpace: Smalltalk }"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
CRCStream subclass:#CRC16Stream
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    19
	instanceVariableNames:'byteSwapped'
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'System-Crypt-Hashing'
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!CRC16Stream class methodsFor:'documentation'!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2003 by eXept Software AG
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
	      All Rights Reserved
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
4899
a1b3e12f6ac0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4874
diff changeset
    43
     Only use CRC to protect against communication errors;
a1b3e12f6ac0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4874
diff changeset
    44
     DO NOT use CRC for cryptography, authentication, security, etc.
a1b3e12f6ac0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4874
diff changeset
    45
     - use secure hashes for those instead.
a1b3e12f6ac0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4874
diff changeset
    46
a1b3e12f6ac0 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4874
diff changeset
    47
    ATTENTION: CRC16Stream is currently BROKEN (in development)
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    48
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    49
    crc16 is a full zoo of different implementations;
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    50
    they differ in the polynom, the initial value and the final xor value.
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    51
    Also, some return an MSB, others an LSB first value (i.e. byteswapped).
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    52
    Make sure to use the correct one:
4874
9ead0ae602b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4870
diff changeset
    53
    
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    newCRC_CCITT:
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    55
      Standard CRC method as defined by CCITT with FFFF as start value 
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
      (ITU-T-T30, ITU-T V42, ITU-T X25, RFC1331, RFC1662, ISO/IEC FCD14443-3).
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
      This is used in data link protocols such as HDLC, SS7, and ISDN.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    59
      The polynomial is
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        x^16 + x^12 + x^5 + 1
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    newCRC_DNP:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
      Standard CRC method as defined by DNP.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
      This is used in data link protocols such as HDLC, SS7, and ISDN.
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    65
      DNP 3.0, or distributed network protocol is a communication protocol 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    66
      designed for use between substation computers, RTUs remote terminal units, 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    67
      IEDs intelligent electronic devices 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    68
      and master stations for the electric utility industry. 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    69
      It is now also used in familiar industries like waste water treatment, 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    70
      transportation and the oil and gas industry.
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    71
      The polynomial is 0x3d65
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    73
    newKERMIT:
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    74
      CRC as used in kermit protocol
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    76
    newMODBUS:
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    77
      CRC as used in the modbus protocol
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
    78
      
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    [author:]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        Claus Gittinger
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    [instance variables:]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    [class variables:]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    [see also:]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        SHA1Stream
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        MD5Stream
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
examples
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
  expect xxx:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
                                                                [exBegin]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    self information:(CRC16Stream hashValueOf:'resume') hexPrintString
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
                                                                [exEnd]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
  expect xxx:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
                                                                [exBegin]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    self information:(CRC16Stream new
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
                            nextPut:$r;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
                            nextPut:$e;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
                            nextPut:$s;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
                            nextPut:$u;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                            nextPut:$m;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
                            nextPut:$e;
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
                            hashValue) hexPrintString
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
                                                                [exEnd]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
  expect xxx:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
                                                                [exBegin]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    self information:(CRC16Stream hashValueOf:#[1 2 3 4 5 6 7]) hexPrintString
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
                                                                [exEnd]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
  expect xxx:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                                                                [exBegin]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    self information:((CRC16Stream hashValueOf:#[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
             16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
             16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
             16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]) hexPrintString)
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
                                                                [exEnd]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
  expect xxx:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
  timing throughput:
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
                                                                [exBegin]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    |hashStream n t|
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    hashStream := CRC16Stream new.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    n := 1000000.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    t := Time millisecondsToRun:[
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
            n timesRepeat:[
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
                hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
            ].
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
         ].
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    t := (t / 1000) asFloat.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    Transcript show:'crc16:'; showCR: hashStream hashValue hexPrintString.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'.
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    Transcript show:(n*50/1024 / t); showCR:' Kb/s'
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                                                                [exEnd]
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!CRC16Stream class methodsFor:'instance creation'!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
generatorPolynomMSB:anInteger
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "notice, in literature, the generator polynom is usually specified as an MSB number"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    ^ self generatorPolynom:(anInteger bitReversed16)
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "Created: / 16-03-2019 / 20:58:49 / Claus Gittinger"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
generatorPolynomMSB:anInteger initValue:initValue
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    "notice, in literature, the generator polynom is usually specified as an MSB number"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    ^ self generatorPolynom:(anInteger bitReversed16) initValue:initValue
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    "Created: / 16-03-2019 / 21:12:24 / Claus Gittinger"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
generatorPolynomMSB:anInteger initValue:initValueArg xorOut:xorOut
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    "notice, in literature, the generator polynom is usually specified as an MSB number"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    ^ self generatorPolynom:(anInteger bitReversed16) initValue:initValueArg xorOut:xorOut
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    "Created: / 16-03-2019 / 21:29:04 / Claus Gittinger"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
new
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    "return an instance of the CCITT CRC-16"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    ^ self newCCITT
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    "Created: / 16-03-2019 / 21:33:36 / Claus Gittinger"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
newCCITT
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   181
    "return an instance of the CCITT CRC-16 with FFFF as initial value
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   182
        x16 + x12 + x5 + 1 "
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
4858
8ba5358392d2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4848
diff changeset
   184
    "/ 16r1021 bitReversed16 => 16r8408
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   185
    self error:'currently broken'.
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   186
    ^ self generatorPolynomMSB:16r1021 initValue:16rFFFF xorOut:0
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    "Created: / 16-03-2019 / 21:13:11 / Claus Gittinger"
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   189
    "Modified: / 25-03-2019 / 14:32:39 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   190
!
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   191
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   192
newCCITT_1D0F
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   193
    "return an instance of the CCITT CRC-16 with 1D0F as initial value
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   194
        x16 + x12 + x5 + 1 "
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   195
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   196
    "/ 16r1021 bitReversed16 => 16r8408
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   197
    self error:'currently broken'.
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   198
    ^ self generatorPolynomMSB:16r1021 initValue:16r1D0F xorOut:0
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   199
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   200
    "Created: / 24-03-2019 / 20:57:32 / Claus Gittinger"
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   201
    "Modified: / 25-03-2019 / 14:33:05 / Claus Gittinger"
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   202
!
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   203
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   204
newCRC_16
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   205
    "return an instance of the CRC-16
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   206
        x16 + x15 + x2 + 1 "
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   207
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   208
    "/ 16r8005 bitReversed16 => 16rA001
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   209
    self error:'currently broken'.
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   210
    ^ self generatorPolynomMSB:16rA001 initValue:0 xorOut:16rFFFF
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   211
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   212
    "Created: / 17-03-2019 / 13:59:52 / Claus Gittinger"
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   213
    "Modified: / 25-03-2019 / 14:32:06 / Claus Gittinger"
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
newDNP
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "return an instance of the DNP CRC-16
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   218
        x16 + x13 + x12 + x11 + x10 + x8 + x6 + x5 + x2 + 1
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   220
     DNP 3.0, or distributed network protocol is a communication protocol 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   221
     designed for use between substation computers, RTUs remote terminal units, 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   222
     IEDs intelligent electronic devices 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   223
     and master stations for the electric utility industry. 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   224
     It is now also used in familiar industries like waste water treatment, 
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   225
     transportation and the oil and gas industry."
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   226
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   227
    "/ 16r3d65 bitReversed16 hexPrintString -> 'A6BC'
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   228
    ^ (self generatorPolynom:16rA6BC initValue:0 xorOut:16rFFFF) byteSwapped:true
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    "Created: / 16-03-2019 / 20:50:03 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   231
    "Modified: / 24-03-2019 / 21:17:58 / Claus Gittinger"
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   234
newKERMIT
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   235
    "return an instance of the CRC-16 used by kermit
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   236
        2r11110101100101
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   237
        x16 + x13 + x12 + x11 + x10 + x8 + x6 + x5 + x2 + 1 "
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   238
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   239
    "/ 16r1021 bitReversed16 => 16r8408
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   240
    ^ (self generatorPolynomMSB:16r1021 initValue:0 xorOut:0) byteSwapped:true
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   241
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   242
    "Created: / 17-03-2019 / 13:51:20 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   243
    "Modified: / 24-03-2019 / 20:10:31 / Claus Gittinger"
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   244
!
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   245
4870
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   246
newMODBUS
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   247
    "return an instance of the MODBUS CRC-16
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   248
        x16 + x15 + x2 + 1 "
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   249
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   250
    "/ 16r8005 bitReversed16 => 16rA001
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   251
    ^ self generatorPolynom:16rA001 initValue:16rFFFF xorOut:0
4870
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   252
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   253
    "Created: / 17-03-2019 / 14:22:41 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   254
    "Modified: / 24-03-2019 / 20:08:41 / Claus Gittinger"
4870
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   255
!
d4870b9aa0e5 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4865
diff changeset
   256
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   257
newXMODEM
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   258
    "return an instance of the XMODEM protocol
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   259
        x16 + x12 + x5 + 1
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   260
        1 2r0001000000100001 "
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   261
        
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   262
    self error:'currently broken'.
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   263
    ^ self generatorPolynom:16r1021 initValue:0 xorOut:0
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   264
    "/ ^ self generatorPolynomMSB:16r1021 initValue:0 xorOut:0
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   266
    "Created: / 24-03-2019 / 20:16:08 / Claus Gittinger"
4918
fbda05fa45dc #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 4905
diff changeset
   267
    "Modified: / 25-03-2019 / 14:31:41 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   268
! !
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   269
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   270
!CRC16Stream class methodsFor:'queries'!
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   272
hashSize
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   273
    "return the size of the hashvalue returned by instances of this class (in bytes)"
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   274
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   275
    ^ 2
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   276
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   277
    "Created: / 24-03-2019 / 12:53:05 / Claus Gittinger"
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
! !
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!CRC16Stream methodsFor:'initialization'!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   282
byteSwapped
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   283
    ^ byteSwapped ? false
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   284
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   285
    "Created: / 24-03-2019 / 20:10:12 / Claus Gittinger"
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   286
!
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   287
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   288
byteSwapped:aBoolean
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   289
    byteSwapped := aBoolean
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   290
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   291
    "Created: / 24-03-2019 / 20:10:01 / Claus Gittinger"
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   292
!
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   293
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   294
generatorPolynom:anLSBInteger
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   295
    "set the generator polynom for this instance,
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   296
     set start and xorOut to 16rFFFF.
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
     Note: you have to set the bit-reversed value, so the LSB must be first"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   299
    self generatorPolynom:anLSBInteger 
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   300
         initValue:16rFFFF xorOut:16rFFFF.
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    "Modified: / 16-03-2019 / 21:24:35 / Claus Gittinger"
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   303
    "Modified (format): / 17-03-2019 / 14:02:47 / Claus Gittinger"
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   306
generatorPolynom:anLSBInteger initValue:initValueArg
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    "set the generator polynom for this instance.
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   308
     set start to initValueArg and xorOut to 16rFFFF.
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
     Note: you have to set the bit-reversed value, so the LSB must be first"
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   311
    self generatorPolynom:anLSBInteger 
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   312
         initValue:initValueArg xorOut:16rFFFF
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    "Created: / 16-03-2019 / 21:24:03 / Claus Gittinger"
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   315
    "Modified (format): / 17-03-2019 / 14:02:57 / Claus Gittinger"
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   316
! !
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   317
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   318
!CRC16Stream methodsFor:'queries'!
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   319
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   320
hashValue
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   321
    "return the computed CRC.
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   322
     For unknown reasons, the standard crc16 needs byte swapping"
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   323
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   324
    |hv|
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   325
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   326
    hv := super hashValue.
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   327
    (byteSwapped == true) ifTrue:[
4865
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   328
        ^ hv byteSwapped16
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   329
    ].    
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   330
    ^ hv.
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   331
93698664b4aa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4862
diff changeset
   332
    "Created: / 17-03-2019 / 13:45:29 / Claus Gittinger"
4905
dc9731862841 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4899
diff changeset
   333
    "Modified: / 24-03-2019 / 20:11:49 / Claus Gittinger"
4848
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
! !
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
!CRC16Stream class methodsFor:'documentation'!
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
version_CVS
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    ^ '$Header$'
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
! !
320b11a3048f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341