@@ -14,38 +14,38 @@ package crc
1414// Parameters represents set of parameters defining a particular CRC algorithm.
1515type Parameters struct {
1616 Width uint // Width of the CRC expressed in bits
17- Polynom uint64 // Polynom used in this CRC calculation
18- ReflectIn bool // Refin indicates whether input bytes should be reflected
19- ReflectOut bool // Refout indicates whether input bytes should be reflected
17+ Polynomial uint64 // Polynomial used in this CRC calculation
18+ ReflectIn bool // ReflectIn indicates whether input bytes should be reflected
19+ ReflectOut bool // ReflectOut indicates whether input bytes should be reflected
2020 Init uint64 // Init is initial value for CRC calculation
2121 FinalXor uint64 // Xor is a value for final xor to be applied before returning result
2222}
2323
2424var (
2525 // CCITT CRC parameters
26- CCITT = & Parameters {Width : 16 , Polynom : 0x1021 , Init : 0xFFFF , ReflectIn : false , ReflectOut : false , FinalXor : 0x0 }
26+ CCITT = & Parameters {Width : 16 , Polynomial : 0x1021 , Init : 0xFFFF , ReflectIn : false , ReflectOut : false , FinalXor : 0x0 }
2727 // CRC16 CRC parameters, also known as ARC
28- CRC16 = & Parameters {Width : 16 , Polynom : 0x8005 , Init : 0x0000 , ReflectIn : true , ReflectOut : true , FinalXor : 0x0 }
28+ CRC16 = & Parameters {Width : 16 , Polynomial : 0x8005 , Init : 0x0000 , ReflectIn : true , ReflectOut : true , FinalXor : 0x0 }
2929 // XMODEM is a set of CRC parameters commonly referred as "XMODEM"
30- XMODEM = & Parameters {Width : 16 , Polynom : 0x1021 , Init : 0x0000 , ReflectIn : false , ReflectOut : false , FinalXor : 0x0 }
30+ XMODEM = & Parameters {Width : 16 , Polynomial : 0x1021 , Init : 0x0000 , ReflectIn : false , ReflectOut : false , FinalXor : 0x0 }
3131 // XMODEM2 is another set of CRC parameters commonly referred as "XMODEM"
32- XMODEM2 = & Parameters {Width : 16 , Polynom : 0x8408 , Init : 0x0000 , ReflectIn : true , ReflectOut : true , FinalXor : 0x0 }
32+ XMODEM2 = & Parameters {Width : 16 , Polynomial : 0x8408 , Init : 0x0000 , ReflectIn : true , ReflectOut : true , FinalXor : 0x0 }
3333
3434 // CRC32 is by far the the most commonly used CRC-32 polynom and set of parameters
35- CRC32 = & Parameters {Width : 32 , Polynom : 0x04C11DB7 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
35+ CRC32 = & Parameters {Width : 32 , Polynomial : 0x04C11DB7 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
3636 // IEEE is an alias to CRC32
3737 IEEE = CRC32
3838 // Castagnoli polynomial. used in iSCSI. And also provided by hash/crc32 package.
39- Castagnoli = & Parameters {Width : 32 , Polynom : 0x1EDC6F41 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
39+ Castagnoli = & Parameters {Width : 32 , Polynomial : 0x1EDC6F41 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
4040 // CRC32C is an alias to Castagnoli
4141 CRC32C = Castagnoli
4242 // Koopman polynomial
43- Koopman = & Parameters {Width : 32 , Polynom : 0x741B8CD7 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
43+ Koopman = & Parameters {Width : 32 , Polynomial : 0x741B8CD7 , Init : 0xFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFF }
4444
4545 // CRC64ISO is set of parameters commonly known as CRC64-ISO
46- CRC64ISO = & Parameters {Width : 64 , Polynom : 0x000000000000001B , Init : 0xFFFFFFFFFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFFFFFFFFFF }
46+ CRC64ISO = & Parameters {Width : 64 , Polynomial : 0x000000000000001B , Init : 0xFFFFFFFFFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFFFFFFFFFF }
4747 // CRC64ECMA is set of parameters commonly known as CRC64-ECMA
48- CRC64ECMA = & Parameters {Width : 64 , Polynom : 0x42F0E1EBA9EA3693 , Init : 0xFFFFFFFFFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFFFFFFFFFF }
48+ CRC64ECMA = & Parameters {Width : 64 , Polynomial : 0x42F0E1EBA9EA3693 , Init : 0xFFFFFFFFFFFFFFFF , ReflectIn : true , ReflectOut : true , FinalXor : 0xFFFFFFFFFFFFFFFF }
4949)
5050
5151// reflect reverses order of last count bits
@@ -81,7 +81,7 @@ func CalculateCRC(crcParams *Parameters, data []byte) uint64 {
8181 curValue ^= (curByte << (crcParams .Width - 8 ))
8282 for j := 0 ; j < 8 ; j ++ {
8383 if (curValue & topbit ) != 0 {
84- curValue = (curValue << 1 ) ^ crcParams .Polynom
84+ curValue = (curValue << 1 ) ^ crcParams .Polynomial
8585 } else {
8686 curValue = (curValue << 1 )
8787 }
@@ -168,14 +168,14 @@ func (h *Hash) CRC() uint64 {
168168 return (ret ^ h .crcParams .FinalXor ) & h .mask
169169}
170170
171- // CalculateCRC is a convinience function allowing to calculate CRC in one call.
171+ // CalculateCRC is a convenience function allowing to calculate CRC in one call.
172172func (h * Hash ) CalculateCRC (data []byte ) uint64 {
173173 h .Reset () // just in case
174174 h .Update (data )
175175 return h .CRC ()
176176}
177177
178- // NewHash creates a new Hash isnstance configured for table driven
178+ // NewHash creates a new Hash instance configured for table driven
179179// CRC calculation according to parameters specified.
180180func NewHash (crcParams * Parameters ) * Hash {
181181 ret := & Hash {crcParams : * crcParams }
@@ -197,13 +197,13 @@ func NewHash(crcParams *Parameters) *Hash {
197197 return ret
198198}
199199
200- // CRC16 is a convinience method to spare end users from explicit type conversion every time this package is used.
200+ // CRC16 is a convenience method to spare end users from explicit type conversion every time this package is used.
201201// Underneath, it just calls CRC() method.
202202func (h * Hash ) CRC16 () uint16 {
203203 return uint16 (h .CRC ())
204204}
205205
206- // CRC32 is a convinience method to spare end users from explicit type conversion every time this package is used.
206+ // CRC32 is a convenience method to spare end users from explicit type conversion every time this package is used.
207207// Underneath, it just calls CRC() method.
208208func (h * Hash ) CRC32 () uint32 {
209209 return uint32 (h .CRC ())
0 commit comments