Skip to content

Commit 703a531

Browse files
committed
Fixed typos
1 parent c930105 commit 703a531

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

crc.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,38 @@ package crc
1414
// Parameters represents set of parameters defining a particular CRC algorithm.
1515
type 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

2424
var (
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.
172172
func (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.
180180
func 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.
202202
func (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.
208208
func (h *Hash) CRC32() uint32 {
209209
return uint32(h.CRC())

crc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestCRCAlgorithms(t *testing.T) {
8282

8383
func TestSizeMethods(t *testing.T) {
8484
testWidth := func(width uint, expectedSize int) {
85-
h := NewHash(&Parameters{Width: width, Polynom: 1})
85+
h := NewHash(&Parameters{Width: width, Polynomial: 1})
8686
s := h.Size()
8787
if s != expectedSize {
8888
t.Errorf("Incorrect Size calculated for width %d: %d when should be %d", width, s, expectedSize)
@@ -139,7 +139,7 @@ func TestHashInterface(t *testing.T) {
139139
}
140140
}
141141

142-
doTest(&Parameters{Width: 8, Polynom: 0x07, Init: 0x00, ReflectIn: false, ReflectOut: false, FinalXor: 0x00}, "123456789", 0xf4)
142+
doTest(&Parameters{Width: 8, Polynomial: 0x07, Init: 0x00, ReflectIn: false, ReflectOut: false, FinalXor: 0x00}, "123456789", 0xf4)
143143
doTest(CCITT, "12345678901234567890", 0xDA31)
144144
doTest(CRC64ECMA, "Introduction on CRC calculations", 0xCF8C40119AE90DCB)
145145
doTest(CRC32C, "Whenever digital data is stored or interfaced, data corruption might occur. Since the beginning of computer science, people have been thinking of ways to deal with this type of problem. For serial data they came up with the solution to attach a parity bit to each sent byte. This simple detection mechanism works if an odd number of bits in a byte changes, but an even number of false bits in one byte will not be detected by the parity check. To overcome this problem people have searched for mathematical sound mechanisms to detect multiple false bits.", 0x864FDAFC)

0 commit comments

Comments
 (0)