authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-26 15:57:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-26 16:07:53-07:00
logc646f0e182d0161946be607a1c310767291f0722
tree4fc0cbcdc2c9f316e512ac53ab9189e8742c72d9
parent030e7d3567328e5948f721ae2b7dbd95d94f0b7a

std.hash.crc: embrace standard names


7 files changed, 476 insertions(+), 502 deletions(-)

lib/std/compress/xz/Decompress.zig+2-2
...@@ -2,8 +2,8 @@ const Decompress = @This();...@@ -2,8 +2,8 @@ const Decompress = @This();
2const std = @import("../../std.zig");2const std = @import("../../std.zig");
3const Allocator = std.mem.Allocator;3const Allocator = std.mem.Allocator;
4const ArrayList = std.ArrayList;4const ArrayList = std.ArrayList;
5const Crc32 = std.hash.Crc32;5const Crc32 = std.hash.crc.@"CRC-32/ISO-HDLC";
6const Crc64 = std.hash.crc.Crc64Xz;6const Crc64 = std.hash.crc.@"CRC-64/XZ";
7const Sha256 = std.crypto.hash.sha2.Sha256;7const Sha256 = std.crypto.hash.sha2.Sha256;
8const lzma2 = std.compress.lzma2;8const lzma2 = std.compress.lzma2;
9const Writer = std.Io.Writer;9const Writer = std.Io.Writer;
lib/std/hash.zig+1-1
...@@ -6,7 +6,7 @@ pub const autoHashStrat = auto_hash.hash;...@@ -6,7 +6,7 @@ pub const autoHashStrat = auto_hash.hash;
6pub const Strategy = auto_hash.HashStrategy;6pub const Strategy = auto_hash.HashStrategy;
77
8pub const crc = @import("hash/crc.zig");8pub const crc = @import("hash/crc.zig");
9pub const Crc32 = crc.Crc32IsoHdlc;9pub const Crc32 = crc.@"CRC-32/ISO-HDLC";
1010
11const fnv = @import("hash/fnv.zig");11const fnv = @import("hash/fnv.zig");
12pub const Fnv1a_32 = fnv.Fnv1a_32;12pub const Fnv1a_32 = fnv.Fnv1a_32;
lib/std/hash/crc.zig+113-113
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
22
3const builtin = @import("builtin");3const builtin = @import("builtin");
44
5pub const Crc32Iscsi = if (builtin.cpu.hasAll(.x86, &.{ .@"64bit", .crc32 }))5pub const @"CRC-32/ISCSI" = if (builtin.cpu.hasAll(.x86, &.{ .@"64bit", .crc32 }))
6 @import("crc/Crc32c.zig")6 @import("crc/Crc32c.zig")
7else7else
8 Generic(u32, .{8 Generic(u32, .{
...@@ -13,7 +13,7 @@ else...@@ -13,7 +13,7 @@ else
13 .xor_output = 0xffffffff,13 .xor_output = 0xffffffff,
14 });14 });
1515
16pub const Crc3Gsm = Generic(u3, .{16pub const @"CRC-3/GSM" = Generic(u3, .{
17 .polynomial = 0x3,17 .polynomial = 0x3,
18 .initial = 0x0,18 .initial = 0x0,
19 .reflect_input = false,19 .reflect_input = false,
...@@ -21,7 +21,7 @@ pub const Crc3Gsm = Generic(u3, .{...@@ -21,7 +21,7 @@ pub const Crc3Gsm = Generic(u3, .{
21 .xor_output = 0x7,21 .xor_output = 0x7,
22});22});
2323
24pub const Crc3Rohc = Generic(u3, .{24pub const @"CRC-3/ROHC" = Generic(u3, .{
25 .polynomial = 0x3,25 .polynomial = 0x3,
26 .initial = 0x7,26 .initial = 0x7,
27 .reflect_input = true,27 .reflect_input = true,
...@@ -29,7 +29,7 @@ pub const Crc3Rohc = Generic(u3, .{...@@ -29,7 +29,7 @@ pub const Crc3Rohc = Generic(u3, .{
29 .xor_output = 0x0,29 .xor_output = 0x0,
30});30});
3131
32pub const Crc4G704 = Generic(u4, .{32pub const @"CRC-4/G-704" = Generic(u4, .{
33 .polynomial = 0x3,33 .polynomial = 0x3,
34 .initial = 0x0,34 .initial = 0x0,
35 .reflect_input = true,35 .reflect_input = true,
...@@ -37,7 +37,7 @@ pub const Crc4G704 = Generic(u4, .{...@@ -37,7 +37,7 @@ pub const Crc4G704 = Generic(u4, .{
37 .xor_output = 0x0,37 .xor_output = 0x0,
38});38});
3939
40pub const Crc4Interlaken = Generic(u4, .{40pub const @"CRC-4/INTERLAKEN" = Generic(u4, .{
41 .polynomial = 0x3,41 .polynomial = 0x3,
42 .initial = 0xf,42 .initial = 0xf,
43 .reflect_input = false,43 .reflect_input = false,
...@@ -45,7 +45,7 @@ pub const Crc4Interlaken = Generic(u4, .{...@@ -45,7 +45,7 @@ pub const Crc4Interlaken = Generic(u4, .{
45 .xor_output = 0xf,45 .xor_output = 0xf,
46});46});
4747
48pub const Crc5EpcC1g2 = Generic(u5, .{48pub const @"CRC-5/EPC-C1G2" = Generic(u5, .{
49 .polynomial = 0x09,49 .polynomial = 0x09,
50 .initial = 0x09,50 .initial = 0x09,
51 .reflect_input = false,51 .reflect_input = false,
...@@ -53,7 +53,7 @@ pub const Crc5EpcC1g2 = Generic(u5, .{...@@ -53,7 +53,7 @@ pub const Crc5EpcC1g2 = Generic(u5, .{
53 .xor_output = 0x00,53 .xor_output = 0x00,
54});54});
5555
56pub const Crc5G704 = Generic(u5, .{56pub const @"CRC-5/G-704" = Generic(u5, .{
57 .polynomial = 0x15,57 .polynomial = 0x15,
58 .initial = 0x00,58 .initial = 0x00,
59 .reflect_input = true,59 .reflect_input = true,
...@@ -61,7 +61,7 @@ pub const Crc5G704 = Generic(u5, .{...@@ -61,7 +61,7 @@ pub const Crc5G704 = Generic(u5, .{
61 .xor_output = 0x00,61 .xor_output = 0x00,
62});62});
6363
64pub const Crc5Usb = Generic(u5, .{64pub const @"CRC-5/USB" = Generic(u5, .{
65 .polynomial = 0x05,65 .polynomial = 0x05,
66 .initial = 0x1f,66 .initial = 0x1f,
67 .reflect_input = true,67 .reflect_input = true,
...@@ -69,7 +69,7 @@ pub const Crc5Usb = Generic(u5, .{...@@ -69,7 +69,7 @@ pub const Crc5Usb = Generic(u5, .{
69 .xor_output = 0x1f,69 .xor_output = 0x1f,
70});70});
7171
72pub const Crc6Cdma2000A = Generic(u6, .{72pub const @"CRC-6/CDMA2000-A" = Generic(u6, .{
73 .polynomial = 0x27,73 .polynomial = 0x27,
74 .initial = 0x3f,74 .initial = 0x3f,
75 .reflect_input = false,75 .reflect_input = false,
...@@ -77,7 +77,7 @@ pub const Crc6Cdma2000A = Generic(u6, .{...@@ -77,7 +77,7 @@ pub const Crc6Cdma2000A = Generic(u6, .{
77 .xor_output = 0x00,77 .xor_output = 0x00,
78});78});
7979
80pub const Crc6Cdma2000B = Generic(u6, .{80pub const @"CRC-6/CDMA2000-B" = Generic(u6, .{
81 .polynomial = 0x07,81 .polynomial = 0x07,
82 .initial = 0x3f,82 .initial = 0x3f,
83 .reflect_input = false,83 .reflect_input = false,
...@@ -85,7 +85,7 @@ pub const Crc6Cdma2000B = Generic(u6, .{...@@ -85,7 +85,7 @@ pub const Crc6Cdma2000B = Generic(u6, .{
85 .xor_output = 0x00,85 .xor_output = 0x00,
86});86});
8787
88pub const Crc6Darc = Generic(u6, .{88pub const @"CRC-6/DARC" = Generic(u6, .{
89 .polynomial = 0x19,89 .polynomial = 0x19,
90 .initial = 0x00,90 .initial = 0x00,
91 .reflect_input = true,91 .reflect_input = true,
...@@ -93,7 +93,7 @@ pub const Crc6Darc = Generic(u6, .{...@@ -93,7 +93,7 @@ pub const Crc6Darc = Generic(u6, .{
93 .xor_output = 0x00,93 .xor_output = 0x00,
94});94});
9595
96pub const Crc6G704 = Generic(u6, .{96pub const @"CRC-6/G-704" = Generic(u6, .{
97 .polynomial = 0x03,97 .polynomial = 0x03,
98 .initial = 0x00,98 .initial = 0x00,
99 .reflect_input = true,99 .reflect_input = true,
...@@ -101,7 +101,7 @@ pub const Crc6G704 = Generic(u6, .{...@@ -101,7 +101,7 @@ pub const Crc6G704 = Generic(u6, .{
101 .xor_output = 0x00,101 .xor_output = 0x00,
102});102});
103103
104pub const Crc6Gsm = Generic(u6, .{104pub const @"CRC-6/GSM" = Generic(u6, .{
105 .polynomial = 0x2f,105 .polynomial = 0x2f,
106 .initial = 0x00,106 .initial = 0x00,
107 .reflect_input = false,107 .reflect_input = false,
...@@ -109,7 +109,7 @@ pub const Crc6Gsm = Generic(u6, .{...@@ -109,7 +109,7 @@ pub const Crc6Gsm = Generic(u6, .{
109 .xor_output = 0x3f,109 .xor_output = 0x3f,
110});110});
111111
112pub const Crc7Mmc = Generic(u7, .{112pub const @"CRC-7/MMC" = Generic(u7, .{
113 .polynomial = 0x09,113 .polynomial = 0x09,
114 .initial = 0x00,114 .initial = 0x00,
115 .reflect_input = false,115 .reflect_input = false,
...@@ -117,7 +117,7 @@ pub const Crc7Mmc = Generic(u7, .{...@@ -117,7 +117,7 @@ pub const Crc7Mmc = Generic(u7, .{
117 .xor_output = 0x00,117 .xor_output = 0x00,
118});118});
119119
120pub const Crc7Rohc = Generic(u7, .{120pub const @"CRC-7/ROHC" = Generic(u7, .{
121 .polynomial = 0x4f,121 .polynomial = 0x4f,
122 .initial = 0x7f,122 .initial = 0x7f,
123 .reflect_input = true,123 .reflect_input = true,
...@@ -125,7 +125,7 @@ pub const Crc7Rohc = Generic(u7, .{...@@ -125,7 +125,7 @@ pub const Crc7Rohc = Generic(u7, .{
125 .xor_output = 0x00,125 .xor_output = 0x00,
126});126});
127127
128pub const Crc7Umts = Generic(u7, .{128pub const @"CRC-7/UMTS" = Generic(u7, .{
129 .polynomial = 0x45,129 .polynomial = 0x45,
130 .initial = 0x00,130 .initial = 0x00,
131 .reflect_input = false,131 .reflect_input = false,
...@@ -133,7 +133,7 @@ pub const Crc7Umts = Generic(u7, .{...@@ -133,7 +133,7 @@ pub const Crc7Umts = Generic(u7, .{
133 .xor_output = 0x00,133 .xor_output = 0x00,
134});134});
135135
136pub const Crc8Autosar = Generic(u8, .{136pub const @"CRC-8/AUTOSAR" = Generic(u8, .{
137 .polynomial = 0x2f,137 .polynomial = 0x2f,
138 .initial = 0xff,138 .initial = 0xff,
139 .reflect_input = false,139 .reflect_input = false,
...@@ -141,7 +141,7 @@ pub const Crc8Autosar = Generic(u8, .{...@@ -141,7 +141,7 @@ pub const Crc8Autosar = Generic(u8, .{
141 .xor_output = 0xff,141 .xor_output = 0xff,
142});142});
143143
144pub const Crc8Bluetooth = Generic(u8, .{144pub const @"CRC-8/BLUETOOTH" = Generic(u8, .{
145 .polynomial = 0xa7,145 .polynomial = 0xa7,
146 .initial = 0x00,146 .initial = 0x00,
147 .reflect_input = true,147 .reflect_input = true,
...@@ -149,7 +149,7 @@ pub const Crc8Bluetooth = Generic(u8, .{...@@ -149,7 +149,7 @@ pub const Crc8Bluetooth = Generic(u8, .{
149 .xor_output = 0x00,149 .xor_output = 0x00,
150});150});
151151
152pub const Crc8Cdma2000 = Generic(u8, .{152pub const @"CRC-8/CDMA2000" = Generic(u8, .{
153 .polynomial = 0x9b,153 .polynomial = 0x9b,
154 .initial = 0xff,154 .initial = 0xff,
155 .reflect_input = false,155 .reflect_input = false,
...@@ -157,7 +157,7 @@ pub const Crc8Cdma2000 = Generic(u8, .{...@@ -157,7 +157,7 @@ pub const Crc8Cdma2000 = Generic(u8, .{
157 .xor_output = 0x00,157 .xor_output = 0x00,
158});158});
159159
160pub const Crc8Darc = Generic(u8, .{160pub const @"CRC-8/DARC" = Generic(u8, .{
161 .polynomial = 0x39,161 .polynomial = 0x39,
162 .initial = 0x00,162 .initial = 0x00,
163 .reflect_input = true,163 .reflect_input = true,
...@@ -165,7 +165,7 @@ pub const Crc8Darc = Generic(u8, .{...@@ -165,7 +165,7 @@ pub const Crc8Darc = Generic(u8, .{
165 .xor_output = 0x00,165 .xor_output = 0x00,
166});166});
167167
168pub const Crc8DvbS2 = Generic(u8, .{168pub const @"CRC-8/DVB-S2" = Generic(u8, .{
169 .polynomial = 0xd5,169 .polynomial = 0xd5,
170 .initial = 0x00,170 .initial = 0x00,
171 .reflect_input = false,171 .reflect_input = false,
...@@ -173,7 +173,7 @@ pub const Crc8DvbS2 = Generic(u8, .{...@@ -173,7 +173,7 @@ pub const Crc8DvbS2 = Generic(u8, .{
173 .xor_output = 0x00,173 .xor_output = 0x00,
174});174});
175175
176pub const Crc8GsmA = Generic(u8, .{176pub const @"CRC-8/GSM-A" = Generic(u8, .{
177 .polynomial = 0x1d,177 .polynomial = 0x1d,
178 .initial = 0x00,178 .initial = 0x00,
179 .reflect_input = false,179 .reflect_input = false,
...@@ -181,7 +181,7 @@ pub const Crc8GsmA = Generic(u8, .{...@@ -181,7 +181,7 @@ pub const Crc8GsmA = Generic(u8, .{
181 .xor_output = 0x00,181 .xor_output = 0x00,
182});182});
183183
184pub const Crc8GsmB = Generic(u8, .{184pub const @"CRC-8/GSM-B" = Generic(u8, .{
185 .polynomial = 0x49,185 .polynomial = 0x49,
186 .initial = 0x00,186 .initial = 0x00,
187 .reflect_input = false,187 .reflect_input = false,
...@@ -189,7 +189,7 @@ pub const Crc8GsmB = Generic(u8, .{...@@ -189,7 +189,7 @@ pub const Crc8GsmB = Generic(u8, .{
189 .xor_output = 0xff,189 .xor_output = 0xff,
190});190});
191191
192pub const Crc8Hitag = Generic(u8, .{192pub const @"CRC-8/HITAG" = Generic(u8, .{
193 .polynomial = 0x1d,193 .polynomial = 0x1d,
194 .initial = 0xff,194 .initial = 0xff,
195 .reflect_input = false,195 .reflect_input = false,
...@@ -197,7 +197,7 @@ pub const Crc8Hitag = Generic(u8, .{...@@ -197,7 +197,7 @@ pub const Crc8Hitag = Generic(u8, .{
197 .xor_output = 0x00,197 .xor_output = 0x00,
198});198});
199199
200pub const Crc8I4321 = Generic(u8, .{200pub const @"CRC-8/I-432-1" = Generic(u8, .{
201 .polynomial = 0x07,201 .polynomial = 0x07,
202 .initial = 0x00,202 .initial = 0x00,
203 .reflect_input = false,203 .reflect_input = false,
...@@ -205,7 +205,7 @@ pub const Crc8I4321 = Generic(u8, .{...@@ -205,7 +205,7 @@ pub const Crc8I4321 = Generic(u8, .{
205 .xor_output = 0x55,205 .xor_output = 0x55,
206});206});
207207
208pub const Crc8ICode = Generic(u8, .{208pub const @"CRC-8/I-CODE" = Generic(u8, .{
209 .polynomial = 0x1d,209 .polynomial = 0x1d,
210 .initial = 0xfd,210 .initial = 0xfd,
211 .reflect_input = false,211 .reflect_input = false,
...@@ -213,7 +213,7 @@ pub const Crc8ICode = Generic(u8, .{...@@ -213,7 +213,7 @@ pub const Crc8ICode = Generic(u8, .{
213 .xor_output = 0x00,213 .xor_output = 0x00,
214});214});
215215
216pub const Crc8Lte = Generic(u8, .{216pub const @"CRC-8/LTE" = Generic(u8, .{
217 .polynomial = 0x9b,217 .polynomial = 0x9b,
218 .initial = 0x00,218 .initial = 0x00,
219 .reflect_input = false,219 .reflect_input = false,
...@@ -221,7 +221,7 @@ pub const Crc8Lte = Generic(u8, .{...@@ -221,7 +221,7 @@ pub const Crc8Lte = Generic(u8, .{
221 .xor_output = 0x00,221 .xor_output = 0x00,
222});222});
223223
224pub const Crc8MaximDow = Generic(u8, .{224pub const @"CRC-8/MAXIM-DOW" = Generic(u8, .{
225 .polynomial = 0x31,225 .polynomial = 0x31,
226 .initial = 0x00,226 .initial = 0x00,
227 .reflect_input = true,227 .reflect_input = true,
...@@ -229,7 +229,7 @@ pub const Crc8MaximDow = Generic(u8, .{...@@ -229,7 +229,7 @@ pub const Crc8MaximDow = Generic(u8, .{
229 .xor_output = 0x00,229 .xor_output = 0x00,
230});230});
231231
232pub const Crc8MifareMad = Generic(u8, .{232pub const @"CRC-8/MIFARE-MAD" = Generic(u8, .{
233 .polynomial = 0x1d,233 .polynomial = 0x1d,
234 .initial = 0xc7,234 .initial = 0xc7,
235 .reflect_input = false,235 .reflect_input = false,
...@@ -237,7 +237,7 @@ pub const Crc8MifareMad = Generic(u8, .{...@@ -237,7 +237,7 @@ pub const Crc8MifareMad = Generic(u8, .{
237 .xor_output = 0x00,237 .xor_output = 0x00,
238});238});
239239
240pub const Crc8Nrsc5 = Generic(u8, .{240pub const @"CRC-8/NRSC-5" = Generic(u8, .{
241 .polynomial = 0x31,241 .polynomial = 0x31,
242 .initial = 0xff,242 .initial = 0xff,
243 .reflect_input = false,243 .reflect_input = false,
...@@ -245,7 +245,7 @@ pub const Crc8Nrsc5 = Generic(u8, .{...@@ -245,7 +245,7 @@ pub const Crc8Nrsc5 = Generic(u8, .{
245 .xor_output = 0x00,245 .xor_output = 0x00,
246});246});
247247
248pub const Crc8Opensafety = Generic(u8, .{248pub const @"CRC-8/OPENSAFETY" = Generic(u8, .{
249 .polynomial = 0x2f,249 .polynomial = 0x2f,
250 .initial = 0x00,250 .initial = 0x00,
251 .reflect_input = false,251 .reflect_input = false,
...@@ -253,7 +253,7 @@ pub const Crc8Opensafety = Generic(u8, .{...@@ -253,7 +253,7 @@ pub const Crc8Opensafety = Generic(u8, .{
253 .xor_output = 0x00,253 .xor_output = 0x00,
254});254});
255255
256pub const Crc8Rohc = Generic(u8, .{256pub const @"CRC-8/ROHC" = Generic(u8, .{
257 .polynomial = 0x07,257 .polynomial = 0x07,
258 .initial = 0xff,258 .initial = 0xff,
259 .reflect_input = true,259 .reflect_input = true,
...@@ -261,7 +261,7 @@ pub const Crc8Rohc = Generic(u8, .{...@@ -261,7 +261,7 @@ pub const Crc8Rohc = Generic(u8, .{
261 .xor_output = 0x00,261 .xor_output = 0x00,
262});262});
263263
264pub const Crc8SaeJ1850 = Generic(u8, .{264pub const @"CRC-8/SAE-J1850" = Generic(u8, .{
265 .polynomial = 0x1d,265 .polynomial = 0x1d,
266 .initial = 0xff,266 .initial = 0xff,
267 .reflect_input = false,267 .reflect_input = false,
...@@ -269,7 +269,7 @@ pub const Crc8SaeJ1850 = Generic(u8, .{...@@ -269,7 +269,7 @@ pub const Crc8SaeJ1850 = Generic(u8, .{
269 .xor_output = 0xff,269 .xor_output = 0xff,
270});270});
271271
272pub const Crc8Smbus = Generic(u8, .{272pub const @"CRC-8/SMBUS" = Generic(u8, .{
273 .polynomial = 0x07,273 .polynomial = 0x07,
274 .initial = 0x00,274 .initial = 0x00,
275 .reflect_input = false,275 .reflect_input = false,
...@@ -277,7 +277,7 @@ pub const Crc8Smbus = Generic(u8, .{...@@ -277,7 +277,7 @@ pub const Crc8Smbus = Generic(u8, .{
277 .xor_output = 0x00,277 .xor_output = 0x00,
278});278});
279279
280pub const Crc8Tech3250 = Generic(u8, .{280pub const @"CRC-8/TECH-3250" = Generic(u8, .{
281 .polynomial = 0x1d,281 .polynomial = 0x1d,
282 .initial = 0xff,282 .initial = 0xff,
283 .reflect_input = true,283 .reflect_input = true,
...@@ -285,7 +285,7 @@ pub const Crc8Tech3250 = Generic(u8, .{...@@ -285,7 +285,7 @@ pub const Crc8Tech3250 = Generic(u8, .{
285 .xor_output = 0x00,285 .xor_output = 0x00,
286});286});
287287
288pub const Crc8Wcdma = Generic(u8, .{288pub const @"CRC-8/WCDMA" = Generic(u8, .{
289 .polynomial = 0x9b,289 .polynomial = 0x9b,
290 .initial = 0x00,290 .initial = 0x00,
291 .reflect_input = true,291 .reflect_input = true,
...@@ -293,7 +293,7 @@ pub const Crc8Wcdma = Generic(u8, .{...@@ -293,7 +293,7 @@ pub const Crc8Wcdma = Generic(u8, .{
293 .xor_output = 0x00,293 .xor_output = 0x00,
294});294});
295295
296pub const Crc10Atm = Generic(u10, .{296pub const @"CRC-10/ATM" = Generic(u10, .{
297 .polynomial = 0x233,297 .polynomial = 0x233,
298 .initial = 0x000,298 .initial = 0x000,
299 .reflect_input = false,299 .reflect_input = false,
...@@ -301,7 +301,7 @@ pub const Crc10Atm = Generic(u10, .{...@@ -301,7 +301,7 @@ pub const Crc10Atm = Generic(u10, .{
301 .xor_output = 0x000,301 .xor_output = 0x000,
302});302});
303303
304pub const Crc10Cdma2000 = Generic(u10, .{304pub const @"CRC-10/CDMA2000" = Generic(u10, .{
305 .polynomial = 0x3d9,305 .polynomial = 0x3d9,
306 .initial = 0x3ff,306 .initial = 0x3ff,
307 .reflect_input = false,307 .reflect_input = false,
...@@ -309,7 +309,7 @@ pub const Crc10Cdma2000 = Generic(u10, .{...@@ -309,7 +309,7 @@ pub const Crc10Cdma2000 = Generic(u10, .{
309 .xor_output = 0x000,309 .xor_output = 0x000,
310});310});
311311
312pub const Crc10Gsm = Generic(u10, .{312pub const @"CRC-10/GSM" = Generic(u10, .{
313 .polynomial = 0x175,313 .polynomial = 0x175,
314 .initial = 0x000,314 .initial = 0x000,
315 .reflect_input = false,315 .reflect_input = false,
...@@ -317,7 +317,7 @@ pub const Crc10Gsm = Generic(u10, .{...@@ -317,7 +317,7 @@ pub const Crc10Gsm = Generic(u10, .{
317 .xor_output = 0x3ff,317 .xor_output = 0x3ff,
318});318});
319319
320pub const Crc11Flexray = Generic(u11, .{320pub const @"CRC-11/FLEXRAY" = Generic(u11, .{
321 .polynomial = 0x385,321 .polynomial = 0x385,
322 .initial = 0x01a,322 .initial = 0x01a,
323 .reflect_input = false,323 .reflect_input = false,
...@@ -325,7 +325,7 @@ pub const Crc11Flexray = Generic(u11, .{...@@ -325,7 +325,7 @@ pub const Crc11Flexray = Generic(u11, .{
325 .xor_output = 0x000,325 .xor_output = 0x000,
326});326});
327327
328pub const Crc11Umts = Generic(u11, .{328pub const @"CRC-11/UMTS" = Generic(u11, .{
329 .polynomial = 0x307,329 .polynomial = 0x307,
330 .initial = 0x000,330 .initial = 0x000,
331 .reflect_input = false,331 .reflect_input = false,
...@@ -333,7 +333,7 @@ pub const Crc11Umts = Generic(u11, .{...@@ -333,7 +333,7 @@ pub const Crc11Umts = Generic(u11, .{
333 .xor_output = 0x000,333 .xor_output = 0x000,
334});334});
335335
336pub const Crc12Cdma2000 = Generic(u12, .{336pub const @"CRC-12/CDMA2000" = Generic(u12, .{
337 .polynomial = 0xf13,337 .polynomial = 0xf13,
338 .initial = 0xfff,338 .initial = 0xfff,
339 .reflect_input = false,339 .reflect_input = false,
...@@ -341,7 +341,7 @@ pub const Crc12Cdma2000 = Generic(u12, .{...@@ -341,7 +341,7 @@ pub const Crc12Cdma2000 = Generic(u12, .{
341 .xor_output = 0x000,341 .xor_output = 0x000,
342});342});
343343
344pub const Crc12Dect = Generic(u12, .{344pub const @"CRC-12/DECT" = Generic(u12, .{
345 .polynomial = 0x80f,345 .polynomial = 0x80f,
346 .initial = 0x000,346 .initial = 0x000,
347 .reflect_input = false,347 .reflect_input = false,
...@@ -349,7 +349,7 @@ pub const Crc12Dect = Generic(u12, .{...@@ -349,7 +349,7 @@ pub const Crc12Dect = Generic(u12, .{
349 .xor_output = 0x000,349 .xor_output = 0x000,
350});350});
351351
352pub const Crc12Gsm = Generic(u12, .{352pub const @"CRC-12/GSM" = Generic(u12, .{
353 .polynomial = 0xd31,353 .polynomial = 0xd31,
354 .initial = 0x000,354 .initial = 0x000,
355 .reflect_input = false,355 .reflect_input = false,
...@@ -357,7 +357,7 @@ pub const Crc12Gsm = Generic(u12, .{...@@ -357,7 +357,7 @@ pub const Crc12Gsm = Generic(u12, .{
357 .xor_output = 0xfff,357 .xor_output = 0xfff,
358});358});
359359
360pub const Crc12Umts = Generic(u12, .{360pub const @"CRC-12/UMTS" = Generic(u12, .{
361 .polynomial = 0x80f,361 .polynomial = 0x80f,
362 .initial = 0x000,362 .initial = 0x000,
363 .reflect_input = false,363 .reflect_input = false,
...@@ -365,7 +365,7 @@ pub const Crc12Umts = Generic(u12, .{...@@ -365,7 +365,7 @@ pub const Crc12Umts = Generic(u12, .{
365 .xor_output = 0x000,365 .xor_output = 0x000,
366});366});
367367
368pub const Crc13Bbc = Generic(u13, .{368pub const @"CRC-13/BBC" = Generic(u13, .{
369 .polynomial = 0x1cf5,369 .polynomial = 0x1cf5,
370 .initial = 0x0000,370 .initial = 0x0000,
371 .reflect_input = false,371 .reflect_input = false,
...@@ -373,7 +373,7 @@ pub const Crc13Bbc = Generic(u13, .{...@@ -373,7 +373,7 @@ pub const Crc13Bbc = Generic(u13, .{
373 .xor_output = 0x0000,373 .xor_output = 0x0000,
374});374});
375375
376pub const Crc14Darc = Generic(u14, .{376pub const @"CRC-14/DARC" = Generic(u14, .{
377 .polynomial = 0x0805,377 .polynomial = 0x0805,
378 .initial = 0x0000,378 .initial = 0x0000,
379 .reflect_input = true,379 .reflect_input = true,
...@@ -381,7 +381,7 @@ pub const Crc14Darc = Generic(u14, .{...@@ -381,7 +381,7 @@ pub const Crc14Darc = Generic(u14, .{
381 .xor_output = 0x0000,381 .xor_output = 0x0000,
382});382});
383383
384pub const Crc14Gsm = Generic(u14, .{384pub const @"CRC-14/GSM" = Generic(u14, .{
385 .polynomial = 0x202d,385 .polynomial = 0x202d,
386 .initial = 0x0000,386 .initial = 0x0000,
387 .reflect_input = false,387 .reflect_input = false,
...@@ -389,7 +389,7 @@ pub const Crc14Gsm = Generic(u14, .{...@@ -389,7 +389,7 @@ pub const Crc14Gsm = Generic(u14, .{
389 .xor_output = 0x3fff,389 .xor_output = 0x3fff,
390});390});
391391
392pub const Crc15Can = Generic(u15, .{392pub const @"CRC-15/CAN" = Generic(u15, .{
393 .polynomial = 0x4599,393 .polynomial = 0x4599,
394 .initial = 0x0000,394 .initial = 0x0000,
395 .reflect_input = false,395 .reflect_input = false,
...@@ -397,7 +397,7 @@ pub const Crc15Can = Generic(u15, .{...@@ -397,7 +397,7 @@ pub const Crc15Can = Generic(u15, .{
397 .xor_output = 0x0000,397 .xor_output = 0x0000,
398});398});
399399
400pub const Crc15Mpt1327 = Generic(u15, .{400pub const @"CRC-15/MPT1327" = Generic(u15, .{
401 .polynomial = 0x6815,401 .polynomial = 0x6815,
402 .initial = 0x0000,402 .initial = 0x0000,
403 .reflect_input = false,403 .reflect_input = false,
...@@ -405,7 +405,7 @@ pub const Crc15Mpt1327 = Generic(u15, .{...@@ -405,7 +405,7 @@ pub const Crc15Mpt1327 = Generic(u15, .{
405 .xor_output = 0x0001,405 .xor_output = 0x0001,
406});406});
407407
408pub const Crc16Arc = Generic(u16, .{408pub const @"CRC-16/ARC" = Generic(u16, .{
409 .polynomial = 0x8005,409 .polynomial = 0x8005,
410 .initial = 0x0000,410 .initial = 0x0000,
411 .reflect_input = true,411 .reflect_input = true,
...@@ -413,7 +413,7 @@ pub const Crc16Arc = Generic(u16, .{...@@ -413,7 +413,7 @@ pub const Crc16Arc = Generic(u16, .{
413 .xor_output = 0x0000,413 .xor_output = 0x0000,
414});414});
415415
416pub const Crc16Cdma2000 = Generic(u16, .{416pub const @"CRC-16/CDMA2000" = Generic(u16, .{
417 .polynomial = 0xc867,417 .polynomial = 0xc867,
418 .initial = 0xffff,418 .initial = 0xffff,
419 .reflect_input = false,419 .reflect_input = false,
...@@ -421,7 +421,7 @@ pub const Crc16Cdma2000 = Generic(u16, .{...@@ -421,7 +421,7 @@ pub const Crc16Cdma2000 = Generic(u16, .{
421 .xor_output = 0x0000,421 .xor_output = 0x0000,
422});422});
423423
424pub const Crc16Cms = Generic(u16, .{424pub const @"CRC-16/CMS" = Generic(u16, .{
425 .polynomial = 0x8005,425 .polynomial = 0x8005,
426 .initial = 0xffff,426 .initial = 0xffff,
427 .reflect_input = false,427 .reflect_input = false,
...@@ -429,7 +429,7 @@ pub const Crc16Cms = Generic(u16, .{...@@ -429,7 +429,7 @@ pub const Crc16Cms = Generic(u16, .{
429 .xor_output = 0x0000,429 .xor_output = 0x0000,
430});430});
431431
432pub const Crc16Dds110 = Generic(u16, .{432pub const @"CRC-16/DDS-110" = Generic(u16, .{
433 .polynomial = 0x8005,433 .polynomial = 0x8005,
434 .initial = 0x800d,434 .initial = 0x800d,
435 .reflect_input = false,435 .reflect_input = false,
...@@ -437,7 +437,7 @@ pub const Crc16Dds110 = Generic(u16, .{...@@ -437,7 +437,7 @@ pub const Crc16Dds110 = Generic(u16, .{
437 .xor_output = 0x0000,437 .xor_output = 0x0000,
438});438});
439439
440pub const Crc16DectR = Generic(u16, .{440pub const @"CRC-16/DECT-R" = Generic(u16, .{
441 .polynomial = 0x0589,441 .polynomial = 0x0589,
442 .initial = 0x0000,442 .initial = 0x0000,
443 .reflect_input = false,443 .reflect_input = false,
...@@ -445,7 +445,7 @@ pub const Crc16DectR = Generic(u16, .{...@@ -445,7 +445,7 @@ pub const Crc16DectR = Generic(u16, .{
445 .xor_output = 0x0001,445 .xor_output = 0x0001,
446});446});
447447
448pub const Crc16DectX = Generic(u16, .{448pub const @"CRC-16/DECT-X" = Generic(u16, .{
449 .polynomial = 0x0589,449 .polynomial = 0x0589,
450 .initial = 0x0000,450 .initial = 0x0000,
451 .reflect_input = false,451 .reflect_input = false,
...@@ -453,7 +453,7 @@ pub const Crc16DectX = Generic(u16, .{...@@ -453,7 +453,7 @@ pub const Crc16DectX = Generic(u16, .{
453 .xor_output = 0x0000,453 .xor_output = 0x0000,
454});454});
455455
456pub const Crc16Dnp = Generic(u16, .{456pub const @"CRC-16/DNP" = Generic(u16, .{
457 .polynomial = 0x3d65,457 .polynomial = 0x3d65,
458 .initial = 0x0000,458 .initial = 0x0000,
459 .reflect_input = true,459 .reflect_input = true,
...@@ -461,7 +461,7 @@ pub const Crc16Dnp = Generic(u16, .{...@@ -461,7 +461,7 @@ pub const Crc16Dnp = Generic(u16, .{
461 .xor_output = 0xffff,461 .xor_output = 0xffff,
462});462});
463463
464pub const Crc16En13757 = Generic(u16, .{464pub const @"CRC-16/EN-13757" = Generic(u16, .{
465 .polynomial = 0x3d65,465 .polynomial = 0x3d65,
466 .initial = 0x0000,466 .initial = 0x0000,
467 .reflect_input = false,467 .reflect_input = false,
...@@ -469,7 +469,7 @@ pub const Crc16En13757 = Generic(u16, .{...@@ -469,7 +469,7 @@ pub const Crc16En13757 = Generic(u16, .{
469 .xor_output = 0xffff,469 .xor_output = 0xffff,
470});470});
471471
472pub const Crc16Genibus = Generic(u16, .{472pub const @"CRC-16/GENIBUS" = Generic(u16, .{
473 .polynomial = 0x1021,473 .polynomial = 0x1021,
474 .initial = 0xffff,474 .initial = 0xffff,
475 .reflect_input = false,475 .reflect_input = false,
...@@ -477,7 +477,7 @@ pub const Crc16Genibus = Generic(u16, .{...@@ -477,7 +477,7 @@ pub const Crc16Genibus = Generic(u16, .{
477 .xor_output = 0xffff,477 .xor_output = 0xffff,
478});478});
479479
480pub const Crc16Gsm = Generic(u16, .{480pub const @"CRC-16/GSM" = Generic(u16, .{
481 .polynomial = 0x1021,481 .polynomial = 0x1021,
482 .initial = 0x0000,482 .initial = 0x0000,
483 .reflect_input = false,483 .reflect_input = false,
...@@ -485,7 +485,7 @@ pub const Crc16Gsm = Generic(u16, .{...@@ -485,7 +485,7 @@ pub const Crc16Gsm = Generic(u16, .{
485 .xor_output = 0xffff,485 .xor_output = 0xffff,
486});486});
487487
488pub const Crc16Ibm3740 = Generic(u16, .{488pub const @"CRC-16/IBM-3740" = Generic(u16, .{
489 .polynomial = 0x1021,489 .polynomial = 0x1021,
490 .initial = 0xffff,490 .initial = 0xffff,
491 .reflect_input = false,491 .reflect_input = false,
...@@ -493,7 +493,7 @@ pub const Crc16Ibm3740 = Generic(u16, .{...@@ -493,7 +493,7 @@ pub const Crc16Ibm3740 = Generic(u16, .{
493 .xor_output = 0x0000,493 .xor_output = 0x0000,
494});494});
495495
496pub const Crc16IbmSdlc = Generic(u16, .{496pub const @"CRC-16/IBM-SDLC" = Generic(u16, .{
497 .polynomial = 0x1021,497 .polynomial = 0x1021,
498 .initial = 0xffff,498 .initial = 0xffff,
499 .reflect_input = true,499 .reflect_input = true,
...@@ -501,7 +501,7 @@ pub const Crc16IbmSdlc = Generic(u16, .{...@@ -501,7 +501,7 @@ pub const Crc16IbmSdlc = Generic(u16, .{
501 .xor_output = 0xffff,501 .xor_output = 0xffff,
502});502});
503503
504pub const Crc16IsoIec144433A = Generic(u16, .{504pub const @"CRC-16/ISO-IEC-14443-3-A" = Generic(u16, .{
505 .polynomial = 0x1021,505 .polynomial = 0x1021,
506 .initial = 0xc6c6,506 .initial = 0xc6c6,
507 .reflect_input = true,507 .reflect_input = true,
...@@ -509,7 +509,7 @@ pub const Crc16IsoIec144433A = Generic(u16, .{...@@ -509,7 +509,7 @@ pub const Crc16IsoIec144433A = Generic(u16, .{
509 .xor_output = 0x0000,509 .xor_output = 0x0000,
510});510});
511511
512pub const Crc16Kermit = Generic(u16, .{512pub const @"CRC-16/KERMIT" = Generic(u16, .{
513 .polynomial = 0x1021,513 .polynomial = 0x1021,
514 .initial = 0x0000,514 .initial = 0x0000,
515 .reflect_input = true,515 .reflect_input = true,
...@@ -517,7 +517,7 @@ pub const Crc16Kermit = Generic(u16, .{...@@ -517,7 +517,7 @@ pub const Crc16Kermit = Generic(u16, .{
517 .xor_output = 0x0000,517 .xor_output = 0x0000,
518});518});
519519
520pub const Crc16Lj1200 = Generic(u16, .{520pub const @"CRC-16/LJ1200" = Generic(u16, .{
521 .polynomial = 0x6f63,521 .polynomial = 0x6f63,
522 .initial = 0x0000,522 .initial = 0x0000,
523 .reflect_input = false,523 .reflect_input = false,
...@@ -525,7 +525,7 @@ pub const Crc16Lj1200 = Generic(u16, .{...@@ -525,7 +525,7 @@ pub const Crc16Lj1200 = Generic(u16, .{
525 .xor_output = 0x0000,525 .xor_output = 0x0000,
526});526});
527527
528pub const Crc16M17 = Generic(u16, .{528pub const @"CRC-16/M17" = Generic(u16, .{
529 .polynomial = 0x5935,529 .polynomial = 0x5935,
530 .initial = 0xffff,530 .initial = 0xffff,
531 .reflect_input = false,531 .reflect_input = false,
...@@ -533,7 +533,7 @@ pub const Crc16M17 = Generic(u16, .{...@@ -533,7 +533,7 @@ pub const Crc16M17 = Generic(u16, .{
533 .xor_output = 0x0000,533 .xor_output = 0x0000,
534});534});
535535
536pub const Crc16MaximDow = Generic(u16, .{536pub const @"CRC-16/MAXIM-DOW" = Generic(u16, .{
537 .polynomial = 0x8005,537 .polynomial = 0x8005,
538 .initial = 0x0000,538 .initial = 0x0000,
539 .reflect_input = true,539 .reflect_input = true,
...@@ -541,7 +541,7 @@ pub const Crc16MaximDow = Generic(u16, .{...@@ -541,7 +541,7 @@ pub const Crc16MaximDow = Generic(u16, .{
541 .xor_output = 0xffff,541 .xor_output = 0xffff,
542});542});
543543
544pub const Crc16Mcrf4xx = Generic(u16, .{544pub const @"CRC-16/MCRF4XX" = Generic(u16, .{
545 .polynomial = 0x1021,545 .polynomial = 0x1021,
546 .initial = 0xffff,546 .initial = 0xffff,
547 .reflect_input = true,547 .reflect_input = true,
...@@ -549,7 +549,7 @@ pub const Crc16Mcrf4xx = Generic(u16, .{...@@ -549,7 +549,7 @@ pub const Crc16Mcrf4xx = Generic(u16, .{
549 .xor_output = 0x0000,549 .xor_output = 0x0000,
550});550});
551551
552pub const Crc16Modbus = Generic(u16, .{552pub const @"CRC-16/MODBUS" = Generic(u16, .{
553 .polynomial = 0x8005,553 .polynomial = 0x8005,
554 .initial = 0xffff,554 .initial = 0xffff,
555 .reflect_input = true,555 .reflect_input = true,
...@@ -557,7 +557,7 @@ pub const Crc16Modbus = Generic(u16, .{...@@ -557,7 +557,7 @@ pub const Crc16Modbus = Generic(u16, .{
557 .xor_output = 0x0000,557 .xor_output = 0x0000,
558});558});
559559
560pub const Crc16Nrsc5 = Generic(u16, .{560pub const @"CRC-16/NRSC-5" = Generic(u16, .{
561 .polynomial = 0x080b,561 .polynomial = 0x080b,
562 .initial = 0xffff,562 .initial = 0xffff,
563 .reflect_input = true,563 .reflect_input = true,
...@@ -565,7 +565,7 @@ pub const Crc16Nrsc5 = Generic(u16, .{...@@ -565,7 +565,7 @@ pub const Crc16Nrsc5 = Generic(u16, .{
565 .xor_output = 0x0000,565 .xor_output = 0x0000,
566});566});
567567
568pub const Crc16OpensafetyA = Generic(u16, .{568pub const @"CRC-16/OPENSAFETY-A" = Generic(u16, .{
569 .polynomial = 0x5935,569 .polynomial = 0x5935,
570 .initial = 0x0000,570 .initial = 0x0000,
571 .reflect_input = false,571 .reflect_input = false,
...@@ -573,7 +573,7 @@ pub const Crc16OpensafetyA = Generic(u16, .{...@@ -573,7 +573,7 @@ pub const Crc16OpensafetyA = Generic(u16, .{
573 .xor_output = 0x0000,573 .xor_output = 0x0000,
574});574});
575575
576pub const Crc16OpensafetyB = Generic(u16, .{576pub const @"CRC-16/OPENSAFETY-B" = Generic(u16, .{
577 .polynomial = 0x755b,577 .polynomial = 0x755b,
578 .initial = 0x0000,578 .initial = 0x0000,
579 .reflect_input = false,579 .reflect_input = false,
...@@ -581,7 +581,7 @@ pub const Crc16OpensafetyB = Generic(u16, .{...@@ -581,7 +581,7 @@ pub const Crc16OpensafetyB = Generic(u16, .{
581 .xor_output = 0x0000,581 .xor_output = 0x0000,
582});582});
583583
584pub const Crc16Profibus = Generic(u16, .{584pub const @"CRC-16/PROFIBUS" = Generic(u16, .{
585 .polynomial = 0x1dcf,585 .polynomial = 0x1dcf,
586 .initial = 0xffff,586 .initial = 0xffff,
587 .reflect_input = false,587 .reflect_input = false,
...@@ -589,7 +589,7 @@ pub const Crc16Profibus = Generic(u16, .{...@@ -589,7 +589,7 @@ pub const Crc16Profibus = Generic(u16, .{
589 .xor_output = 0xffff,589 .xor_output = 0xffff,
590});590});
591591
592pub const Crc16Riello = Generic(u16, .{592pub const @"CRC-16/RIELLO" = Generic(u16, .{
593 .polynomial = 0x1021,593 .polynomial = 0x1021,
594 .initial = 0xb2aa,594 .initial = 0xb2aa,
595 .reflect_input = true,595 .reflect_input = true,
...@@ -597,7 +597,7 @@ pub const Crc16Riello = Generic(u16, .{...@@ -597,7 +597,7 @@ pub const Crc16Riello = Generic(u16, .{
597 .xor_output = 0x0000,597 .xor_output = 0x0000,
598});598});
599599
600pub const Crc16SpiFujitsu = Generic(u16, .{600pub const @"CRC-16/SPI-FUJITSU" = Generic(u16, .{
601 .polynomial = 0x1021,601 .polynomial = 0x1021,
602 .initial = 0x1d0f,602 .initial = 0x1d0f,
603 .reflect_input = false,603 .reflect_input = false,
...@@ -605,7 +605,7 @@ pub const Crc16SpiFujitsu = Generic(u16, .{...@@ -605,7 +605,7 @@ pub const Crc16SpiFujitsu = Generic(u16, .{
605 .xor_output = 0x0000,605 .xor_output = 0x0000,
606});606});
607607
608pub const Crc16T10Dif = Generic(u16, .{608pub const @"CRC-16/T10-DIF" = Generic(u16, .{
609 .polynomial = 0x8bb7,609 .polynomial = 0x8bb7,
610 .initial = 0x0000,610 .initial = 0x0000,
611 .reflect_input = false,611 .reflect_input = false,
...@@ -613,7 +613,7 @@ pub const Crc16T10Dif = Generic(u16, .{...@@ -613,7 +613,7 @@ pub const Crc16T10Dif = Generic(u16, .{
613 .xor_output = 0x0000,613 .xor_output = 0x0000,
614});614});
615615
616pub const Crc16Teledisk = Generic(u16, .{616pub const @"CRC-16/TELEDISK" = Generic(u16, .{
617 .polynomial = 0xa097,617 .polynomial = 0xa097,
618 .initial = 0x0000,618 .initial = 0x0000,
619 .reflect_input = false,619 .reflect_input = false,
...@@ -621,7 +621,7 @@ pub const Crc16Teledisk = Generic(u16, .{...@@ -621,7 +621,7 @@ pub const Crc16Teledisk = Generic(u16, .{
621 .xor_output = 0x0000,621 .xor_output = 0x0000,
622});622});
623623
624pub const Crc16Tms37157 = Generic(u16, .{624pub const @"CRC-16/TMS37157" = Generic(u16, .{
625 .polynomial = 0x1021,625 .polynomial = 0x1021,
626 .initial = 0x89ec,626 .initial = 0x89ec,
627 .reflect_input = true,627 .reflect_input = true,
...@@ -629,7 +629,7 @@ pub const Crc16Tms37157 = Generic(u16, .{...@@ -629,7 +629,7 @@ pub const Crc16Tms37157 = Generic(u16, .{
629 .xor_output = 0x0000,629 .xor_output = 0x0000,
630});630});
631631
632pub const Crc16Umts = Generic(u16, .{632pub const @"CRC-16/UMTS" = Generic(u16, .{
633 .polynomial = 0x8005,633 .polynomial = 0x8005,
634 .initial = 0x0000,634 .initial = 0x0000,
635 .reflect_input = false,635 .reflect_input = false,
...@@ -637,7 +637,7 @@ pub const Crc16Umts = Generic(u16, .{...@@ -637,7 +637,7 @@ pub const Crc16Umts = Generic(u16, .{
637 .xor_output = 0x0000,637 .xor_output = 0x0000,
638});638});
639639
640pub const Crc16Usb = Generic(u16, .{640pub const @"CRC-16/USB" = Generic(u16, .{
641 .polynomial = 0x8005,641 .polynomial = 0x8005,
642 .initial = 0xffff,642 .initial = 0xffff,
643 .reflect_input = true,643 .reflect_input = true,
...@@ -645,7 +645,7 @@ pub const Crc16Usb = Generic(u16, .{...@@ -645,7 +645,7 @@ pub const Crc16Usb = Generic(u16, .{
645 .xor_output = 0xffff,645 .xor_output = 0xffff,
646});646});
647647
648pub const Crc16Xmodem = Generic(u16, .{648pub const @"CRC-16/XMODEM" = Generic(u16, .{
649 .polynomial = 0x1021,649 .polynomial = 0x1021,
650 .initial = 0x0000,650 .initial = 0x0000,
651 .reflect_input = false,651 .reflect_input = false,
...@@ -653,7 +653,7 @@ pub const Crc16Xmodem = Generic(u16, .{...@@ -653,7 +653,7 @@ pub const Crc16Xmodem = Generic(u16, .{
653 .xor_output = 0x0000,653 .xor_output = 0x0000,
654});654});
655655
656pub const Crc17CanFd = Generic(u17, .{656pub const @"CRC-17/CAN-FD" = Generic(u17, .{
657 .polynomial = 0x1685b,657 .polynomial = 0x1685b,
658 .initial = 0x00000,658 .initial = 0x00000,
659 .reflect_input = false,659 .reflect_input = false,
...@@ -661,7 +661,7 @@ pub const Crc17CanFd = Generic(u17, .{...@@ -661,7 +661,7 @@ pub const Crc17CanFd = Generic(u17, .{
661 .xor_output = 0x00000,661 .xor_output = 0x00000,
662});662});
663663
664pub const Crc21CanFd = Generic(u21, .{664pub const @"CRC-21/CAN-FD" = Generic(u21, .{
665 .polynomial = 0x102899,665 .polynomial = 0x102899,
666 .initial = 0x000000,666 .initial = 0x000000,
667 .reflect_input = false,667 .reflect_input = false,
...@@ -669,7 +669,7 @@ pub const Crc21CanFd = Generic(u21, .{...@@ -669,7 +669,7 @@ pub const Crc21CanFd = Generic(u21, .{
669 .xor_output = 0x000000,669 .xor_output = 0x000000,
670});670});
671671
672pub const Crc24Ble = Generic(u24, .{672pub const @"CRC-24/BLE" = Generic(u24, .{
673 .polynomial = 0x00065b,673 .polynomial = 0x00065b,
674 .initial = 0x555555,674 .initial = 0x555555,
675 .reflect_input = true,675 .reflect_input = true,
...@@ -677,7 +677,7 @@ pub const Crc24Ble = Generic(u24, .{...@@ -677,7 +677,7 @@ pub const Crc24Ble = Generic(u24, .{
677 .xor_output = 0x000000,677 .xor_output = 0x000000,
678});678});
679679
680pub const Crc24FlexrayA = Generic(u24, .{680pub const @"CRC-24/FLEXRAY-A" = Generic(u24, .{
681 .polynomial = 0x5d6dcb,681 .polynomial = 0x5d6dcb,
682 .initial = 0xfedcba,682 .initial = 0xfedcba,
683 .reflect_input = false,683 .reflect_input = false,
...@@ -685,7 +685,7 @@ pub const Crc24FlexrayA = Generic(u24, .{...@@ -685,7 +685,7 @@ pub const Crc24FlexrayA = Generic(u24, .{
685 .xor_output = 0x000000,685 .xor_output = 0x000000,
686});686});
687687
688pub const Crc24FlexrayB = Generic(u24, .{688pub const @"CRC-24/FLEXRAY-B" = Generic(u24, .{
689 .polynomial = 0x5d6dcb,689 .polynomial = 0x5d6dcb,
690 .initial = 0xabcdef,690 .initial = 0xabcdef,
691 .reflect_input = false,691 .reflect_input = false,
...@@ -693,7 +693,7 @@ pub const Crc24FlexrayB = Generic(u24, .{...@@ -693,7 +693,7 @@ pub const Crc24FlexrayB = Generic(u24, .{
693 .xor_output = 0x000000,693 .xor_output = 0x000000,
694});694});
695695
696pub const Crc24Interlaken = Generic(u24, .{696pub const @"CRC-24/INTERLAKEN" = Generic(u24, .{
697 .polynomial = 0x328b63,697 .polynomial = 0x328b63,
698 .initial = 0xffffff,698 .initial = 0xffffff,
699 .reflect_input = false,699 .reflect_input = false,
...@@ -701,7 +701,7 @@ pub const Crc24Interlaken = Generic(u24, .{...@@ -701,7 +701,7 @@ pub const Crc24Interlaken = Generic(u24, .{
701 .xor_output = 0xffffff,701 .xor_output = 0xffffff,
702});702});
703703
704pub const Crc24LteA = Generic(u24, .{704pub const @"CRC-24/LTE-A" = Generic(u24, .{
705 .polynomial = 0x864cfb,705 .polynomial = 0x864cfb,
706 .initial = 0x000000,706 .initial = 0x000000,
707 .reflect_input = false,707 .reflect_input = false,
...@@ -709,7 +709,7 @@ pub const Crc24LteA = Generic(u24, .{...@@ -709,7 +709,7 @@ pub const Crc24LteA = Generic(u24, .{
709 .xor_output = 0x000000,709 .xor_output = 0x000000,
710});710});
711711
712pub const Crc24LteB = Generic(u24, .{712pub const @"CRC-24/LTE-B" = Generic(u24, .{
713 .polynomial = 0x800063,713 .polynomial = 0x800063,
714 .initial = 0x000000,714 .initial = 0x000000,
715 .reflect_input = false,715 .reflect_input = false,
...@@ -717,7 +717,7 @@ pub const Crc24LteB = Generic(u24, .{...@@ -717,7 +717,7 @@ pub const Crc24LteB = Generic(u24, .{
717 .xor_output = 0x000000,717 .xor_output = 0x000000,
718});718});
719719
720pub const Crc24Openpgp = Generic(u24, .{720pub const @"CRC-24/OPENPGP" = Generic(u24, .{
721 .polynomial = 0x864cfb,721 .polynomial = 0x864cfb,
722 .initial = 0xb704ce,722 .initial = 0xb704ce,
723 .reflect_input = false,723 .reflect_input = false,
...@@ -725,7 +725,7 @@ pub const Crc24Openpgp = Generic(u24, .{...@@ -725,7 +725,7 @@ pub const Crc24Openpgp = Generic(u24, .{
725 .xor_output = 0x000000,725 .xor_output = 0x000000,
726});726});
727727
728pub const Crc24Os9 = Generic(u24, .{728pub const @"CRC-24/OS-9" = Generic(u24, .{
729 .polynomial = 0x800063,729 .polynomial = 0x800063,
730 .initial = 0xffffff,730 .initial = 0xffffff,
731 .reflect_input = false,731 .reflect_input = false,
...@@ -733,7 +733,7 @@ pub const Crc24Os9 = Generic(u24, .{...@@ -733,7 +733,7 @@ pub const Crc24Os9 = Generic(u24, .{
733 .xor_output = 0xffffff,733 .xor_output = 0xffffff,
734});734});
735735
736pub const Crc30Cdma = Generic(u30, .{736pub const @"CRC-30/CDMA" = Generic(u30, .{
737 .polynomial = 0x2030b9c7,737 .polynomial = 0x2030b9c7,
738 .initial = 0x3fffffff,738 .initial = 0x3fffffff,
739 .reflect_input = false,739 .reflect_input = false,
...@@ -741,7 +741,7 @@ pub const Crc30Cdma = Generic(u30, .{...@@ -741,7 +741,7 @@ pub const Crc30Cdma = Generic(u30, .{
741 .xor_output = 0x3fffffff,741 .xor_output = 0x3fffffff,
742});742});
743743
744pub const Crc31Philips = Generic(u31, .{744pub const @"CRC-31/PHILIPS" = Generic(u31, .{
745 .polynomial = 0x04c11db7,745 .polynomial = 0x04c11db7,
746 .initial = 0x7fffffff,746 .initial = 0x7fffffff,
747 .reflect_input = false,747 .reflect_input = false,
...@@ -749,7 +749,7 @@ pub const Crc31Philips = Generic(u31, .{...@@ -749,7 +749,7 @@ pub const Crc31Philips = Generic(u31, .{
749 .xor_output = 0x7fffffff,749 .xor_output = 0x7fffffff,
750});750});
751751
752pub const Crc32Aixm = Generic(u32, .{752pub const @"CRC-32/AIXM" = Generic(u32, .{
753 .polynomial = 0x814141ab,753 .polynomial = 0x814141ab,
754 .initial = 0x00000000,754 .initial = 0x00000000,
755 .reflect_input = false,755 .reflect_input = false,
...@@ -757,7 +757,7 @@ pub const Crc32Aixm = Generic(u32, .{...@@ -757,7 +757,7 @@ pub const Crc32Aixm = Generic(u32, .{
757 .xor_output = 0x00000000,757 .xor_output = 0x00000000,
758});758});
759759
760pub const Crc32Autosar = Generic(u32, .{760pub const @"CRC-32/AUTOSAR" = Generic(u32, .{
761 .polynomial = 0xf4acfb13,761 .polynomial = 0xf4acfb13,
762 .initial = 0xffffffff,762 .initial = 0xffffffff,
763 .reflect_input = true,763 .reflect_input = true,
...@@ -765,7 +765,7 @@ pub const Crc32Autosar = Generic(u32, .{...@@ -765,7 +765,7 @@ pub const Crc32Autosar = Generic(u32, .{
765 .xor_output = 0xffffffff,765 .xor_output = 0xffffffff,
766});766});
767767
768pub const Crc32Base91D = Generic(u32, .{768pub const @"CRC-32/BASE91-D" = Generic(u32, .{
769 .polynomial = 0xa833982b,769 .polynomial = 0xa833982b,
770 .initial = 0xffffffff,770 .initial = 0xffffffff,
771 .reflect_input = true,771 .reflect_input = true,
...@@ -773,7 +773,7 @@ pub const Crc32Base91D = Generic(u32, .{...@@ -773,7 +773,7 @@ pub const Crc32Base91D = Generic(u32, .{
773 .xor_output = 0xffffffff,773 .xor_output = 0xffffffff,
774});774});
775775
776pub const Crc32Bzip2 = Generic(u32, .{776pub const @"CRC-32/BZIP2" = Generic(u32, .{
777 .polynomial = 0x04c11db7,777 .polynomial = 0x04c11db7,
778 .initial = 0xffffffff,778 .initial = 0xffffffff,
779 .reflect_input = false,779 .reflect_input = false,
...@@ -781,7 +781,7 @@ pub const Crc32Bzip2 = Generic(u32, .{...@@ -781,7 +781,7 @@ pub const Crc32Bzip2 = Generic(u32, .{
781 .xor_output = 0xffffffff,781 .xor_output = 0xffffffff,
782});782});
783783
784pub const Crc32CdRomEdc = Generic(u32, .{784pub const @"CRC-32/CD-ROM-EDC" = Generic(u32, .{
785 .polynomial = 0x8001801b,785 .polynomial = 0x8001801b,
786 .initial = 0x00000000,786 .initial = 0x00000000,
787 .reflect_input = true,787 .reflect_input = true,
...@@ -789,7 +789,7 @@ pub const Crc32CdRomEdc = Generic(u32, .{...@@ -789,7 +789,7 @@ pub const Crc32CdRomEdc = Generic(u32, .{
789 .xor_output = 0x00000000,789 .xor_output = 0x00000000,
790});790});
791791
792pub const Crc32Cksum = Generic(u32, .{792pub const @"CRC-32/CKSUM" = Generic(u32, .{
793 .polynomial = 0x04c11db7,793 .polynomial = 0x04c11db7,
794 .initial = 0x00000000,794 .initial = 0x00000000,
795 .reflect_input = false,795 .reflect_input = false,
...@@ -797,7 +797,7 @@ pub const Crc32Cksum = Generic(u32, .{...@@ -797,7 +797,7 @@ pub const Crc32Cksum = Generic(u32, .{
797 .xor_output = 0xffffffff,797 .xor_output = 0xffffffff,
798});798});
799799
800pub const Crc32IsoHdlc = Generic(u32, .{800pub const @"CRC-32/ISO-HDLC" = Generic(u32, .{
801 .polynomial = 0x04c11db7,801 .polynomial = 0x04c11db7,
802 .initial = 0xffffffff,802 .initial = 0xffffffff,
803 .reflect_input = true,803 .reflect_input = true,
...@@ -805,7 +805,7 @@ pub const Crc32IsoHdlc = Generic(u32, .{...@@ -805,7 +805,7 @@ pub const Crc32IsoHdlc = Generic(u32, .{
805 .xor_output = 0xffffffff,805 .xor_output = 0xffffffff,
806});806});
807807
808pub const Crc32Jamcrc = Generic(u32, .{808pub const @"CRC-32/JAMCRC" = Generic(u32, .{
809 .polynomial = 0x04c11db7,809 .polynomial = 0x04c11db7,
810 .initial = 0xffffffff,810 .initial = 0xffffffff,
811 .reflect_input = true,811 .reflect_input = true,
...@@ -813,7 +813,7 @@ pub const Crc32Jamcrc = Generic(u32, .{...@@ -813,7 +813,7 @@ pub const Crc32Jamcrc = Generic(u32, .{
813 .xor_output = 0x00000000,813 .xor_output = 0x00000000,
814});814});
815815
816pub const Crc32Koopman = Generic(u32, .{816pub const @"CRC-32/KOOPMAN" = Generic(u32, .{
817 .polynomial = 0x741b8cd7,817 .polynomial = 0x741b8cd7,
818 .initial = 0xffffffff,818 .initial = 0xffffffff,
819 .reflect_input = true,819 .reflect_input = true,
...@@ -821,7 +821,7 @@ pub const Crc32Koopman = Generic(u32, .{...@@ -821,7 +821,7 @@ pub const Crc32Koopman = Generic(u32, .{
821 .xor_output = 0xffffffff,821 .xor_output = 0xffffffff,
822});822});
823823
824pub const Crc32Mef = Generic(u32, .{824pub const @"CRC-32/MEF" = Generic(u32, .{
825 .polynomial = 0x741b8cd7,825 .polynomial = 0x741b8cd7,
826 .initial = 0xffffffff,826 .initial = 0xffffffff,
827 .reflect_input = true,827 .reflect_input = true,
...@@ -829,7 +829,7 @@ pub const Crc32Mef = Generic(u32, .{...@@ -829,7 +829,7 @@ pub const Crc32Mef = Generic(u32, .{
829 .xor_output = 0x00000000,829 .xor_output = 0x00000000,
830});830});
831831
832pub const Crc32Mpeg2 = Generic(u32, .{832pub const @"CRC-32/MPEG-2" = Generic(u32, .{
833 .polynomial = 0x04c11db7,833 .polynomial = 0x04c11db7,
834 .initial = 0xffffffff,834 .initial = 0xffffffff,
835 .reflect_input = false,835 .reflect_input = false,
...@@ -837,7 +837,7 @@ pub const Crc32Mpeg2 = Generic(u32, .{...@@ -837,7 +837,7 @@ pub const Crc32Mpeg2 = Generic(u32, .{
837 .xor_output = 0x00000000,837 .xor_output = 0x00000000,
838});838});
839839
840pub const Crc32Xfer = Generic(u32, .{840pub const @"CRC-32/XFER" = Generic(u32, .{
841 .polynomial = 0x000000af,841 .polynomial = 0x000000af,
842 .initial = 0x00000000,842 .initial = 0x00000000,
843 .reflect_input = false,843 .reflect_input = false,
...@@ -845,7 +845,7 @@ pub const Crc32Xfer = Generic(u32, .{...@@ -845,7 +845,7 @@ pub const Crc32Xfer = Generic(u32, .{
845 .xor_output = 0x00000000,845 .xor_output = 0x00000000,
846});846});
847847
848pub const Crc40Gsm = Generic(u40, .{848pub const @"CRC-40/GSM" = Generic(u40, .{
849 .polynomial = 0x0004820009,849 .polynomial = 0x0004820009,
850 .initial = 0x0000000000,850 .initial = 0x0000000000,
851 .reflect_input = false,851 .reflect_input = false,
...@@ -853,7 +853,7 @@ pub const Crc40Gsm = Generic(u40, .{...@@ -853,7 +853,7 @@ pub const Crc40Gsm = Generic(u40, .{
853 .xor_output = 0xffffffffff,853 .xor_output = 0xffffffffff,
854});854});
855855
856pub const Crc64Ecma182 = Generic(u64, .{856pub const @"CRC-64/ECMA-182" = Generic(u64, .{
857 .polynomial = 0x42f0e1eba9ea3693,857 .polynomial = 0x42f0e1eba9ea3693,
858 .initial = 0x0000000000000000,858 .initial = 0x0000000000000000,
859 .reflect_input = false,859 .reflect_input = false,
...@@ -861,7 +861,7 @@ pub const Crc64Ecma182 = Generic(u64, .{...@@ -861,7 +861,7 @@ pub const Crc64Ecma182 = Generic(u64, .{
861 .xor_output = 0x0000000000000000,861 .xor_output = 0x0000000000000000,
862});862});
863863
864pub const Crc64GoIso = Generic(u64, .{864pub const @"CRC-64/GO-ISO" = Generic(u64, .{
865 .polynomial = 0x000000000000001b,865 .polynomial = 0x000000000000001b,
866 .initial = 0xffffffffffffffff,866 .initial = 0xffffffffffffffff,
867 .reflect_input = true,867 .reflect_input = true,
...@@ -869,7 +869,7 @@ pub const Crc64GoIso = Generic(u64, .{...@@ -869,7 +869,7 @@ pub const Crc64GoIso = Generic(u64, .{
869 .xor_output = 0xffffffffffffffff,869 .xor_output = 0xffffffffffffffff,
870});870});
871871
872pub const Crc64Ms = Generic(u64, .{872pub const @"CRC-64/MS" = Generic(u64, .{
873 .polynomial = 0x259c84cba6426349,873 .polynomial = 0x259c84cba6426349,
874 .initial = 0xffffffffffffffff,874 .initial = 0xffffffffffffffff,
875 .reflect_input = true,875 .reflect_input = true,
...@@ -877,7 +877,7 @@ pub const Crc64Ms = Generic(u64, .{...@@ -877,7 +877,7 @@ pub const Crc64Ms = Generic(u64, .{
877 .xor_output = 0x0000000000000000,877 .xor_output = 0x0000000000000000,
878});878});
879879
880pub const Crc64Redis = Generic(u64, .{880pub const @"CRC-64/REDIS" = Generic(u64, .{
881 .polynomial = 0xad93d23594c935a9,881 .polynomial = 0xad93d23594c935a9,
882 .initial = 0x0000000000000000,882 .initial = 0x0000000000000000,
883 .reflect_input = true,883 .reflect_input = true,
...@@ -885,7 +885,7 @@ pub const Crc64Redis = Generic(u64, .{...@@ -885,7 +885,7 @@ pub const Crc64Redis = Generic(u64, .{
885 .xor_output = 0x0000000000000000,885 .xor_output = 0x0000000000000000,
886});886});
887887
888pub const Crc64We = Generic(u64, .{888pub const @"CRC-64/WE" = Generic(u64, .{
889 .polynomial = 0x42f0e1eba9ea3693,889 .polynomial = 0x42f0e1eba9ea3693,
890 .initial = 0xffffffffffffffff,890 .initial = 0xffffffffffffffff,
891 .reflect_input = false,891 .reflect_input = false,
...@@ -893,7 +893,7 @@ pub const Crc64We = Generic(u64, .{...@@ -893,7 +893,7 @@ pub const Crc64We = Generic(u64, .{
893 .xor_output = 0xffffffffffffffff,893 .xor_output = 0xffffffffffffffff,
894});894});
895895
896pub const Crc64Xz = Generic(u64, .{896pub const @"CRC-64/XZ" = Generic(u64, .{
897 .polynomial = 0x42f0e1eba9ea3693,897 .polynomial = 0x42f0e1eba9ea3693,
898 .initial = 0xffffffffffffffff,898 .initial = 0xffffffffffffffff,
899 .reflect_input = true,899 .reflect_input = true,
...@@ -901,7 +901,7 @@ pub const Crc64Xz = Generic(u64, .{...@@ -901,7 +901,7 @@ pub const Crc64Xz = Generic(u64, .{
901 .xor_output = 0xffffffffffffffff,901 .xor_output = 0xffffffffffffffff,
902});902});
903903
904pub const Crc82Darc = Generic(u82, .{904pub const @"CRC-82/DARC" = Generic(u82, .{
905 .polynomial = 0x0308c0111011401440411,905 .polynomial = 0x0308c0111011401440411,
906 .initial = 0x000000000000000000000,906 .initial = 0x000000000000000000000,
907 .reflect_input = true,907 .reflect_input = true,
lib/std/hash/crc/test.zig+351-351
...@@ -6,1264 +6,1264 @@ const verify = @import("../verify.zig");...@@ -6,1264 +6,1264 @@ const verify = @import("../verify.zig");
6const crc = @import("../crc.zig");6const crc = @import("../crc.zig");
77
8test "crc32 ieee regression" {8test "crc32 ieee regression" {
9 const crc32 = crc.Crc32IsoHdlc;9 const Crc = crc.@"CRC-32/ISO-HDLC";
10 try testing.expectEqual(crc32.hash(""), 0x00000000);10 try testing.expectEqual(Crc.hash(""), 0x00000000);
11 try testing.expectEqual(crc32.hash("a"), 0xe8b7be43);11 try testing.expectEqual(Crc.hash("a"), 0xe8b7be43);
12 try testing.expectEqual(crc32.hash("abc"), 0x352441c2);12 try testing.expectEqual(Crc.hash("abc"), 0x352441c2);
13}13}
1414
15test "crc32 castagnoli regression" {15test "crc32 castagnoli regression" {
16 const crc32 = crc.Crc32Iscsi;16 const Crc = crc.@"CRC-32/ISCSI";
17 try testing.expectEqual(crc32.hash(""), 0x00000000);17 try testing.expectEqual(Crc.hash(""), 0x00000000);
18 try testing.expectEqual(crc32.hash("a"), 0xc1d04330);18 try testing.expectEqual(Crc.hash("a"), 0xc1d04330);
19 try testing.expectEqual(crc32.hash("abc"), 0x364b3fb7);19 try testing.expectEqual(Crc.hash("abc"), 0x364b3fb7);
20}20}
2121
22test "crc32 koopman regression" {22test "crc32 koopman regression" {
23 const crc32 = crc.Crc32Koopman;23 const Crc = crc.@"CRC-32/KOOPMAN";
24 try testing.expectEqual(crc32.hash(""), 0x00000000);24 try testing.expectEqual(Crc.hash(""), 0x00000000);
25 try testing.expectEqual(crc32.hash("a"), 0x0da2aa8a);25 try testing.expectEqual(Crc.hash("a"), 0x0da2aa8a);
26 try testing.expectEqual(crc32.hash("abc"), 0xba2322ac);26 try testing.expectEqual(Crc.hash("abc"), 0xba2322ac);
27}27}
2828
29test "CRC-32/ISCSI" {29test "CRC-32/ISCSI" {
30 const Crc32Iscsi = crc.Crc32Iscsi;30 const Crc = crc.@"CRC-32/ISCSI";
3131
32 try testing.expectEqual(@as(u32, 0xe3069283), Crc32Iscsi.hash("123456789"));32 try testing.expectEqual(@as(u32, 0xe3069283), Crc.hash("123456789"));
3333
34 var c = Crc32Iscsi.init();34 var c = Crc.init();
35 c.update("1234");35 c.update("1234");
36 c.update("56789");36 c.update("56789");
37 try testing.expectEqual(@as(u32, 0xe3069283), c.final());37 try testing.expectEqual(@as(u32, 0xe3069283), c.final());
38}38}
3939
40test "CRC-3/GSM" {40test "CRC-3/GSM" {
41 const Crc3Gsm = crc.Crc3Gsm;41 const Crc = crc.@"CRC-3/GSM";
4242
43 try testing.expectEqual(@as(u3, 0x4), Crc3Gsm.hash("123456789"));43 try testing.expectEqual(@as(u3, 0x4), Crc.hash("123456789"));
4444
45 var c = Crc3Gsm.init();45 var c = Crc.init();
46 c.update("1234");46 c.update("1234");
47 c.update("56789");47 c.update("56789");
48 try testing.expectEqual(@as(u3, 0x4), c.final());48 try testing.expectEqual(@as(u3, 0x4), c.final());
49}49}
5050
51test "CRC-3/ROHC" {51test "CRC-3/ROHC" {
52 const Crc3Rohc = crc.Crc3Rohc;52 const Crc = crc.@"CRC-3/ROHC";
5353
54 try testing.expectEqual(@as(u3, 0x6), Crc3Rohc.hash("123456789"));54 try testing.expectEqual(@as(u3, 0x6), Crc.hash("123456789"));
5555
56 var c = Crc3Rohc.init();56 var c = Crc.init();
57 c.update("1234");57 c.update("1234");
58 c.update("56789");58 c.update("56789");
59 try testing.expectEqual(@as(u3, 0x6), c.final());59 try testing.expectEqual(@as(u3, 0x6), c.final());
60}60}
6161
62test "CRC-4/G-704" {62test "CRC-4/G-704" {
63 const Crc4G704 = crc.Crc4G704;63 const Crc = crc.@"CRC-4/G-704";
6464
65 try testing.expectEqual(@as(u4, 0x7), Crc4G704.hash("123456789"));65 try testing.expectEqual(@as(u4, 0x7), Crc.hash("123456789"));
6666
67 var c = Crc4G704.init();67 var c = Crc.init();
68 c.update("1234");68 c.update("1234");
69 c.update("56789");69 c.update("56789");
70 try testing.expectEqual(@as(u4, 0x7), c.final());70 try testing.expectEqual(@as(u4, 0x7), c.final());
71}71}
7272
73test "CRC-4/INTERLAKEN" {73test "CRC-4/INTERLAKEN" {
74 const Crc4Interlaken = crc.Crc4Interlaken;74 const Crc = crc.@"CRC-4/INTERLAKEN";
7575
76 try testing.expectEqual(@as(u4, 0xb), Crc4Interlaken.hash("123456789"));76 try testing.expectEqual(@as(u4, 0xb), Crc.hash("123456789"));
7777
78 var c = Crc4Interlaken.init();78 var c = Crc.init();
79 c.update("1234");79 c.update("1234");
80 c.update("56789");80 c.update("56789");
81 try testing.expectEqual(@as(u4, 0xb), c.final());81 try testing.expectEqual(@as(u4, 0xb), c.final());
82}82}
8383
84test "CRC-5/EPC-C1G2" {84test "CRC-5/EPC-C1G2" {
85 const Crc5EpcC1g2 = crc.Crc5EpcC1g2;85 const Crc = crc.@"CRC-5/EPC-C1G2";
8686
87 try testing.expectEqual(@as(u5, 0x00), Crc5EpcC1g2.hash("123456789"));87 try testing.expectEqual(@as(u5, 0x00), Crc.hash("123456789"));
8888
89 var c = Crc5EpcC1g2.init();89 var c = Crc.init();
90 c.update("1234");90 c.update("1234");
91 c.update("56789");91 c.update("56789");
92 try testing.expectEqual(@as(u5, 0x00), c.final());92 try testing.expectEqual(@as(u5, 0x00), c.final());
93}93}
9494
95test "CRC-5/G-704" {95test "CRC-5/G-704" {
96 const Crc5G704 = crc.Crc5G704;96 const Crc = crc.@"CRC-5/G-704";
9797
98 try testing.expectEqual(@as(u5, 0x07), Crc5G704.hash("123456789"));98 try testing.expectEqual(@as(u5, 0x07), Crc.hash("123456789"));
9999
100 var c = Crc5G704.init();100 var c = Crc.init();
101 c.update("1234");101 c.update("1234");
102 c.update("56789");102 c.update("56789");
103 try testing.expectEqual(@as(u5, 0x07), c.final());103 try testing.expectEqual(@as(u5, 0x07), c.final());
104}104}
105105
106test "CRC-5/USB" {106test "CRC-5/USB" {
107 const Crc5Usb = crc.Crc5Usb;107 const Crc = crc.@"CRC-5/USB";
108108
109 try testing.expectEqual(@as(u5, 0x19), Crc5Usb.hash("123456789"));109 try testing.expectEqual(@as(u5, 0x19), Crc.hash("123456789"));
110110
111 var c = Crc5Usb.init();111 var c = Crc.init();
112 c.update("1234");112 c.update("1234");
113 c.update("56789");113 c.update("56789");
114 try testing.expectEqual(@as(u5, 0x19), c.final());114 try testing.expectEqual(@as(u5, 0x19), c.final());
115}115}
116116
117test "CRC-6/CDMA2000-A" {117test "CRC-6/CDMA2000-A" {
118 const Crc6Cdma2000A = crc.Crc6Cdma2000A;118 const Crc = crc.@"CRC-6/CDMA2000-A";
119119
120 try testing.expectEqual(@as(u6, 0x0d), Crc6Cdma2000A.hash("123456789"));120 try testing.expectEqual(@as(u6, 0x0d), Crc.hash("123456789"));
121121
122 var c = Crc6Cdma2000A.init();122 var c = Crc.init();
123 c.update("1234");123 c.update("1234");
124 c.update("56789");124 c.update("56789");
125 try testing.expectEqual(@as(u6, 0x0d), c.final());125 try testing.expectEqual(@as(u6, 0x0d), c.final());
126}126}
127127
128test "CRC-6/CDMA2000-B" {128test "CRC-6/CDMA2000-B" {
129 const Crc6Cdma2000B = crc.Crc6Cdma2000B;129 const Crc = crc.@"CRC-6/CDMA2000-B";
130130
131 try testing.expectEqual(@as(u6, 0x3b), Crc6Cdma2000B.hash("123456789"));131 try testing.expectEqual(@as(u6, 0x3b), Crc.hash("123456789"));
132132
133 var c = Crc6Cdma2000B.init();133 var c = Crc.init();
134 c.update("1234");134 c.update("1234");
135 c.update("56789");135 c.update("56789");
136 try testing.expectEqual(@as(u6, 0x3b), c.final());136 try testing.expectEqual(@as(u6, 0x3b), c.final());
137}137}
138138
139test "CRC-6/DARC" {139test "CRC-6/DARC" {
140 const Crc6Darc = crc.Crc6Darc;140 const Crc = crc.@"CRC-6/DARC";
141141
142 try testing.expectEqual(@as(u6, 0x26), Crc6Darc.hash("123456789"));142 try testing.expectEqual(@as(u6, 0x26), Crc.hash("123456789"));
143143
144 var c = Crc6Darc.init();144 var c = Crc.init();
145 c.update("1234");145 c.update("1234");
146 c.update("56789");146 c.update("56789");
147 try testing.expectEqual(@as(u6, 0x26), c.final());147 try testing.expectEqual(@as(u6, 0x26), c.final());
148}148}
149149
150test "CRC-6/G-704" {150test "CRC-6/G-704" {
151 const Crc6G704 = crc.Crc6G704;151 const Crc = crc.@"CRC-6/G-704";
152152
153 try testing.expectEqual(@as(u6, 0x06), Crc6G704.hash("123456789"));153 try testing.expectEqual(@as(u6, 0x06), Crc.hash("123456789"));
154154
155 var c = Crc6G704.init();155 var c = Crc.init();
156 c.update("1234");156 c.update("1234");
157 c.update("56789");157 c.update("56789");
158 try testing.expectEqual(@as(u6, 0x06), c.final());158 try testing.expectEqual(@as(u6, 0x06), c.final());
159}159}
160160
161test "CRC-6/GSM" {161test "CRC-6/GSM" {
162 const Crc6Gsm = crc.Crc6Gsm;162 const Crc = crc.@"CRC-6/GSM";
163163
164 try testing.expectEqual(@as(u6, 0x13), Crc6Gsm.hash("123456789"));164 try testing.expectEqual(@as(u6, 0x13), Crc.hash("123456789"));
165165
166 var c = Crc6Gsm.init();166 var c = Crc.init();
167 c.update("1234");167 c.update("1234");
168 c.update("56789");168 c.update("56789");
169 try testing.expectEqual(@as(u6, 0x13), c.final());169 try testing.expectEqual(@as(u6, 0x13), c.final());
170}170}
171171
172test "CRC-7/MMC" {172test "CRC-7/MMC" {
173 const Crc7Mmc = crc.Crc7Mmc;173 const Crc = crc.@"CRC-7/MMC";
174174
175 try testing.expectEqual(@as(u7, 0x75), Crc7Mmc.hash("123456789"));175 try testing.expectEqual(@as(u7, 0x75), Crc.hash("123456789"));
176176
177 var c = Crc7Mmc.init();177 var c = Crc.init();
178 c.update("1234");178 c.update("1234");
179 c.update("56789");179 c.update("56789");
180 try testing.expectEqual(@as(u7, 0x75), c.final());180 try testing.expectEqual(@as(u7, 0x75), c.final());
181}181}
182182
183test "CRC-7/ROHC" {183test "CRC-7/ROHC" {
184 const Crc7Rohc = crc.Crc7Rohc;184 const Crc = crc.@"CRC-7/ROHC";
185185
186 try testing.expectEqual(@as(u7, 0x53), Crc7Rohc.hash("123456789"));186 try testing.expectEqual(@as(u7, 0x53), Crc.hash("123456789"));
187187
188 var c = Crc7Rohc.init();188 var c = Crc.init();
189 c.update("1234");189 c.update("1234");
190 c.update("56789");190 c.update("56789");
191 try testing.expectEqual(@as(u7, 0x53), c.final());191 try testing.expectEqual(@as(u7, 0x53), c.final());
192}192}
193193
194test "CRC-7/UMTS" {194test "CRC-7/UMTS" {
195 const Crc7Umts = crc.Crc7Umts;195 const Crc = crc.@"CRC-7/UMTS";
196196
197 try testing.expectEqual(@as(u7, 0x61), Crc7Umts.hash("123456789"));197 try testing.expectEqual(@as(u7, 0x61), Crc.hash("123456789"));
198198
199 var c = Crc7Umts.init();199 var c = Crc.init();
200 c.update("1234");200 c.update("1234");
201 c.update("56789");201 c.update("56789");
202 try testing.expectEqual(@as(u7, 0x61), c.final());202 try testing.expectEqual(@as(u7, 0x61), c.final());
203}203}
204204
205test "CRC-8/AUTOSAR" {205test "CRC-8/AUTOSAR" {
206 const Crc8Autosar = crc.Crc8Autosar;206 const Crc = crc.@"CRC-8/AUTOSAR";
207207
208 try testing.expectEqual(@as(u8, 0xdf), Crc8Autosar.hash("123456789"));208 try testing.expectEqual(@as(u8, 0xdf), Crc.hash("123456789"));
209209
210 var c = Crc8Autosar.init();210 var c = Crc.init();
211 c.update("1234");211 c.update("1234");
212 c.update("56789");212 c.update("56789");
213 try testing.expectEqual(@as(u8, 0xdf), c.final());213 try testing.expectEqual(@as(u8, 0xdf), c.final());
214}214}
215215
216test "CRC-8/BLUETOOTH" {216test "CRC-8/BLUETOOTH" {
217 const Crc8Bluetooth = crc.Crc8Bluetooth;217 const Crc = crc.@"CRC-8/BLUETOOTH";
218218
219 try testing.expectEqual(@as(u8, 0x26), Crc8Bluetooth.hash("123456789"));219 try testing.expectEqual(@as(u8, 0x26), Crc.hash("123456789"));
220220
221 var c = Crc8Bluetooth.init();221 var c = Crc.init();
222 c.update("1234");222 c.update("1234");
223 c.update("56789");223 c.update("56789");
224 try testing.expectEqual(@as(u8, 0x26), c.final());224 try testing.expectEqual(@as(u8, 0x26), c.final());
225}225}
226226
227test "CRC-8/CDMA2000" {227test "CRC-8/CDMA2000" {
228 const Crc8Cdma2000 = crc.Crc8Cdma2000;228 const Crc = crc.@"CRC-8/CDMA2000";
229229
230 try testing.expectEqual(@as(u8, 0xda), Crc8Cdma2000.hash("123456789"));230 try testing.expectEqual(@as(u8, 0xda), Crc.hash("123456789"));
231231
232 var c = Crc8Cdma2000.init();232 var c = Crc.init();
233 c.update("1234");233 c.update("1234");
234 c.update("56789");234 c.update("56789");
235 try testing.expectEqual(@as(u8, 0xda), c.final());235 try testing.expectEqual(@as(u8, 0xda), c.final());
236}236}
237237
238test "CRC-8/DARC" {238test "CRC-8/DARC" {
239 const Crc8Darc = crc.Crc8Darc;239 const Crc = crc.@"CRC-8/DARC";
240240
241 try testing.expectEqual(@as(u8, 0x15), Crc8Darc.hash("123456789"));241 try testing.expectEqual(@as(u8, 0x15), Crc.hash("123456789"));
242242
243 var c = Crc8Darc.init();243 var c = Crc.init();
244 c.update("1234");244 c.update("1234");
245 c.update("56789");245 c.update("56789");
246 try testing.expectEqual(@as(u8, 0x15), c.final());246 try testing.expectEqual(@as(u8, 0x15), c.final());
247}247}
248248
249test "CRC-8/DVB-S2" {249test "CRC-8/DVB-S2" {
250 const Crc8DvbS2 = crc.Crc8DvbS2;250 const Crc = crc.@"CRC-8/DVB-S2";
251251
252 try testing.expectEqual(@as(u8, 0xbc), Crc8DvbS2.hash("123456789"));252 try testing.expectEqual(@as(u8, 0xbc), Crc.hash("123456789"));
253253
254 var c = Crc8DvbS2.init();254 var c = Crc.init();
255 c.update("1234");255 c.update("1234");
256 c.update("56789");256 c.update("56789");
257 try testing.expectEqual(@as(u8, 0xbc), c.final());257 try testing.expectEqual(@as(u8, 0xbc), c.final());
258}258}
259259
260test "CRC-8/GSM-A" {260test "CRC-8/GSM-A" {
261 const Crc8GsmA = crc.Crc8GsmA;261 const Crc = crc.@"CRC-8/GSM-A";
262262
263 try testing.expectEqual(@as(u8, 0x37), Crc8GsmA.hash("123456789"));263 try testing.expectEqual(@as(u8, 0x37), Crc.hash("123456789"));
264264
265 var c = Crc8GsmA.init();265 var c = Crc.init();
266 c.update("1234");266 c.update("1234");
267 c.update("56789");267 c.update("56789");
268 try testing.expectEqual(@as(u8, 0x37), c.final());268 try testing.expectEqual(@as(u8, 0x37), c.final());
269}269}
270270
271test "CRC-8/GSM-B" {271test "CRC-8/GSM-B" {
272 const Crc8GsmB = crc.Crc8GsmB;272 const Crc = crc.@"CRC-8/GSM-B";
273273
274 try testing.expectEqual(@as(u8, 0x94), Crc8GsmB.hash("123456789"));274 try testing.expectEqual(@as(u8, 0x94), Crc.hash("123456789"));
275275
276 var c = Crc8GsmB.init();276 var c = Crc.init();
277 c.update("1234");277 c.update("1234");
278 c.update("56789");278 c.update("56789");
279 try testing.expectEqual(@as(u8, 0x94), c.final());279 try testing.expectEqual(@as(u8, 0x94), c.final());
280}280}
281281
282test "CRC-8/HITAG" {282test "CRC-8/HITAG" {
283 const Crc8Hitag = crc.Crc8Hitag;283 const Crc = crc.@"CRC-8/HITAG";
284284
285 try testing.expectEqual(@as(u8, 0xb4), Crc8Hitag.hash("123456789"));285 try testing.expectEqual(@as(u8, 0xb4), Crc.hash("123456789"));
286286
287 var c = Crc8Hitag.init();287 var c = Crc.init();
288 c.update("1234");288 c.update("1234");
289 c.update("56789");289 c.update("56789");
290 try testing.expectEqual(@as(u8, 0xb4), c.final());290 try testing.expectEqual(@as(u8, 0xb4), c.final());
291}291}
292292
293test "CRC-8/I-432-1" {293test "CRC-8/I-432-1" {
294 const Crc8I4321 = crc.Crc8I4321;294 const Crc = crc.@"CRC-8/I-432-1";
295295
296 try testing.expectEqual(@as(u8, 0xa1), Crc8I4321.hash("123456789"));296 try testing.expectEqual(@as(u8, 0xa1), Crc.hash("123456789"));
297297
298 var c = Crc8I4321.init();298 var c = Crc.init();
299 c.update("1234");299 c.update("1234");
300 c.update("56789");300 c.update("56789");
301 try testing.expectEqual(@as(u8, 0xa1), c.final());301 try testing.expectEqual(@as(u8, 0xa1), c.final());
302}302}
303303
304test "CRC-8/I-CODE" {304test "CRC-8/I-CODE" {
305 const Crc8ICode = crc.Crc8ICode;305 const Crc = crc.@"CRC-8/I-CODE";
306306
307 try testing.expectEqual(@as(u8, 0x7e), Crc8ICode.hash("123456789"));307 try testing.expectEqual(@as(u8, 0x7e), Crc.hash("123456789"));
308308
309 var c = Crc8ICode.init();309 var c = Crc.init();
310 c.update("1234");310 c.update("1234");
311 c.update("56789");311 c.update("56789");
312 try testing.expectEqual(@as(u8, 0x7e), c.final());312 try testing.expectEqual(@as(u8, 0x7e), c.final());
313}313}
314314
315test "CRC-8/LTE" {315test "CRC-8/LTE" {
316 const Crc8Lte = crc.Crc8Lte;316 const Crc = crc.@"CRC-8/LTE";
317317
318 try testing.expectEqual(@as(u8, 0xea), Crc8Lte.hash("123456789"));318 try testing.expectEqual(@as(u8, 0xea), Crc.hash("123456789"));
319319
320 var c = Crc8Lte.init();320 var c = Crc.init();
321 c.update("1234");321 c.update("1234");
322 c.update("56789");322 c.update("56789");
323 try testing.expectEqual(@as(u8, 0xea), c.final());323 try testing.expectEqual(@as(u8, 0xea), c.final());
324}324}
325325
326test "CRC-8/MAXIM-DOW" {326test "CRC-8/MAXIM-DOW" {
327 const Crc8MaximDow = crc.Crc8MaximDow;327 const Crc = crc.@"CRC-8/MAXIM-DOW";
328328
329 try testing.expectEqual(@as(u8, 0xa1), Crc8MaximDow.hash("123456789"));329 try testing.expectEqual(@as(u8, 0xa1), Crc.hash("123456789"));
330330
331 var c = Crc8MaximDow.init();331 var c = Crc.init();
332 c.update("1234");332 c.update("1234");
333 c.update("56789");333 c.update("56789");
334 try testing.expectEqual(@as(u8, 0xa1), c.final());334 try testing.expectEqual(@as(u8, 0xa1), c.final());
335}335}
336336
337test "CRC-8/MIFARE-MAD" {337test "CRC-8/MIFARE-MAD" {
338 const Crc8MifareMad = crc.Crc8MifareMad;338 const Crc = crc.@"CRC-8/MIFARE-MAD";
339339
340 try testing.expectEqual(@as(u8, 0x99), Crc8MifareMad.hash("123456789"));340 try testing.expectEqual(@as(u8, 0x99), Crc.hash("123456789"));
341341
342 var c = Crc8MifareMad.init();342 var c = Crc.init();
343 c.update("1234");343 c.update("1234");
344 c.update("56789");344 c.update("56789");
345 try testing.expectEqual(@as(u8, 0x99), c.final());345 try testing.expectEqual(@as(u8, 0x99), c.final());
346}346}
347347
348test "CRC-8/NRSC-5" {348test "CRC-8/NRSC-5" {
349 const Crc8Nrsc5 = crc.Crc8Nrsc5;349 const Crc = crc.@"CRC-8/NRSC-5";
350350
351 try testing.expectEqual(@as(u8, 0xf7), Crc8Nrsc5.hash("123456789"));351 try testing.expectEqual(@as(u8, 0xf7), Crc.hash("123456789"));
352352
353 var c = Crc8Nrsc5.init();353 var c = Crc.init();
354 c.update("1234");354 c.update("1234");
355 c.update("56789");355 c.update("56789");
356 try testing.expectEqual(@as(u8, 0xf7), c.final());356 try testing.expectEqual(@as(u8, 0xf7), c.final());
357}357}
358358
359test "CRC-8/OPENSAFETY" {359test "CRC-8/OPENSAFETY" {
360 const Crc8Opensafety = crc.Crc8Opensafety;360 const Crc = crc.@"CRC-8/OPENSAFETY";
361361
362 try testing.expectEqual(@as(u8, 0x3e), Crc8Opensafety.hash("123456789"));362 try testing.expectEqual(@as(u8, 0x3e), Crc.hash("123456789"));
363363
364 var c = Crc8Opensafety.init();364 var c = Crc.init();
365 c.update("1234");365 c.update("1234");
366 c.update("56789");366 c.update("56789");
367 try testing.expectEqual(@as(u8, 0x3e), c.final());367 try testing.expectEqual(@as(u8, 0x3e), c.final());
368}368}
369369
370test "CRC-8/ROHC" {370test "CRC-8/ROHC" {
371 const Crc8Rohc = crc.Crc8Rohc;371 const Crc = crc.@"CRC-8/ROHC";
372372
373 try testing.expectEqual(@as(u8, 0xd0), Crc8Rohc.hash("123456789"));373 try testing.expectEqual(@as(u8, 0xd0), Crc.hash("123456789"));
374374
375 var c = Crc8Rohc.init();375 var c = Crc.init();
376 c.update("1234");376 c.update("1234");
377 c.update("56789");377 c.update("56789");
378 try testing.expectEqual(@as(u8, 0xd0), c.final());378 try testing.expectEqual(@as(u8, 0xd0), c.final());
379}379}
380380
381test "CRC-8/SAE-J1850" {381test "CRC-8/SAE-J1850" {
382 const Crc8SaeJ1850 = crc.Crc8SaeJ1850;382 const Crc = crc.@"CRC-8/SAE-J1850";
383383
384 try testing.expectEqual(@as(u8, 0x4b), Crc8SaeJ1850.hash("123456789"));384 try testing.expectEqual(@as(u8, 0x4b), Crc.hash("123456789"));
385385
386 var c = Crc8SaeJ1850.init();386 var c = Crc.init();
387 c.update("1234");387 c.update("1234");
388 c.update("56789");388 c.update("56789");
389 try testing.expectEqual(@as(u8, 0x4b), c.final());389 try testing.expectEqual(@as(u8, 0x4b), c.final());
390}390}
391391
392test "CRC-8/SMBUS" {392test "CRC-8/SMBUS" {
393 const Crc8Smbus = crc.Crc8Smbus;393 const Crc = crc.@"CRC-8/SMBUS";
394394
395 try testing.expectEqual(@as(u8, 0xf4), Crc8Smbus.hash("123456789"));395 try testing.expectEqual(@as(u8, 0xf4), Crc.hash("123456789"));
396396
397 var c = Crc8Smbus.init();397 var c = Crc.init();
398 c.update("1234");398 c.update("1234");
399 c.update("56789");399 c.update("56789");
400 try testing.expectEqual(@as(u8, 0xf4), c.final());400 try testing.expectEqual(@as(u8, 0xf4), c.final());
401}401}
402402
403test "CRC-8/TECH-3250" {403test "CRC-8/TECH-3250" {
404 const Crc8Tech3250 = crc.Crc8Tech3250;404 const Crc = crc.@"CRC-8/TECH-3250";
405405
406 try testing.expectEqual(@as(u8, 0x97), Crc8Tech3250.hash("123456789"));406 try testing.expectEqual(@as(u8, 0x97), Crc.hash("123456789"));
407407
408 var c = Crc8Tech3250.init();408 var c = Crc.init();
409 c.update("1234");409 c.update("1234");
410 c.update("56789");410 c.update("56789");
411 try testing.expectEqual(@as(u8, 0x97), c.final());411 try testing.expectEqual(@as(u8, 0x97), c.final());
412}412}
413413
414test "CRC-8/WCDMA" {414test "CRC-8/WCDMA" {
415 const Crc8Wcdma = crc.Crc8Wcdma;415 const Crc = crc.@"CRC-8/WCDMA";
416416
417 try testing.expectEqual(@as(u8, 0x25), Crc8Wcdma.hash("123456789"));417 try testing.expectEqual(@as(u8, 0x25), Crc.hash("123456789"));
418418
419 var c = Crc8Wcdma.init();419 var c = Crc.init();
420 c.update("1234");420 c.update("1234");
421 c.update("56789");421 c.update("56789");
422 try testing.expectEqual(@as(u8, 0x25), c.final());422 try testing.expectEqual(@as(u8, 0x25), c.final());
423}423}
424424
425test "CRC-10/ATM" {425test "CRC-10/ATM" {
426 const Crc10Atm = crc.Crc10Atm;426 const Crc = crc.@"CRC-10/ATM";
427427
428 try testing.expectEqual(@as(u10, 0x199), Crc10Atm.hash("123456789"));428 try testing.expectEqual(@as(u10, 0x199), Crc.hash("123456789"));
429429
430 var c = Crc10Atm.init();430 var c = Crc.init();
431 c.update("1234");431 c.update("1234");
432 c.update("56789");432 c.update("56789");
433 try testing.expectEqual(@as(u10, 0x199), c.final());433 try testing.expectEqual(@as(u10, 0x199), c.final());
434}434}
435435
436test "CRC-10/CDMA2000" {436test "CRC-10/CDMA2000" {
437 const Crc10Cdma2000 = crc.Crc10Cdma2000;437 const Crc = crc.@"CRC-10/CDMA2000";
438438
439 try testing.expectEqual(@as(u10, 0x233), Crc10Cdma2000.hash("123456789"));439 try testing.expectEqual(@as(u10, 0x233), Crc.hash("123456789"));
440440
441 var c = Crc10Cdma2000.init();441 var c = Crc.init();
442 c.update("1234");442 c.update("1234");
443 c.update("56789");443 c.update("56789");
444 try testing.expectEqual(@as(u10, 0x233), c.final());444 try testing.expectEqual(@as(u10, 0x233), c.final());
445}445}
446446
447test "CRC-10/GSM" {447test "CRC-10/GSM" {
448 const Crc10Gsm = crc.Crc10Gsm;448 const Crc = crc.@"CRC-10/GSM";
449449
450 try testing.expectEqual(@as(u10, 0x12a), Crc10Gsm.hash("123456789"));450 try testing.expectEqual(@as(u10, 0x12a), Crc.hash("123456789"));
451451
452 var c = Crc10Gsm.init();452 var c = Crc.init();
453 c.update("1234");453 c.update("1234");
454 c.update("56789");454 c.update("56789");
455 try testing.expectEqual(@as(u10, 0x12a), c.final());455 try testing.expectEqual(@as(u10, 0x12a), c.final());
456}456}
457457
458test "CRC-11/FLEXRAY" {458test "CRC-11/FLEXRAY" {
459 const Crc11Flexray = crc.Crc11Flexray;459 const Crc = crc.@"CRC-11/FLEXRAY";
460460
461 try testing.expectEqual(@as(u11, 0x5a3), Crc11Flexray.hash("123456789"));461 try testing.expectEqual(@as(u11, 0x5a3), Crc.hash("123456789"));
462462
463 var c = Crc11Flexray.init();463 var c = Crc.init();
464 c.update("1234");464 c.update("1234");
465 c.update("56789");465 c.update("56789");
466 try testing.expectEqual(@as(u11, 0x5a3), c.final());466 try testing.expectEqual(@as(u11, 0x5a3), c.final());
467}467}
468468
469test "CRC-11/UMTS" {469test "CRC-11/UMTS" {
470 const Crc11Umts = crc.Crc11Umts;470 const Crc = crc.@"CRC-11/UMTS";
471471
472 try testing.expectEqual(@as(u11, 0x061), Crc11Umts.hash("123456789"));472 try testing.expectEqual(@as(u11, 0x061), Crc.hash("123456789"));
473473
474 var c = Crc11Umts.init();474 var c = Crc.init();
475 c.update("1234");475 c.update("1234");
476 c.update("56789");476 c.update("56789");
477 try testing.expectEqual(@as(u11, 0x061), c.final());477 try testing.expectEqual(@as(u11, 0x061), c.final());
478}478}
479479
480test "CRC-12/CDMA2000" {480test "CRC-12/CDMA2000" {
481 const Crc12Cdma2000 = crc.Crc12Cdma2000;481 const Crc = crc.@"CRC-12/CDMA2000";
482482
483 try testing.expectEqual(@as(u12, 0xd4d), Crc12Cdma2000.hash("123456789"));483 try testing.expectEqual(@as(u12, 0xd4d), Crc.hash("123456789"));
484484
485 var c = Crc12Cdma2000.init();485 var c = Crc.init();
486 c.update("1234");486 c.update("1234");
487 c.update("56789");487 c.update("56789");
488 try testing.expectEqual(@as(u12, 0xd4d), c.final());488 try testing.expectEqual(@as(u12, 0xd4d), c.final());
489}489}
490490
491test "CRC-12/DECT" {491test "CRC-12/DECT" {
492 const Crc12Dect = crc.Crc12Dect;492 const Crc = crc.@"CRC-12/DECT";
493493
494 try testing.expectEqual(@as(u12, 0xf5b), Crc12Dect.hash("123456789"));494 try testing.expectEqual(@as(u12, 0xf5b), Crc.hash("123456789"));
495495
496 var c = Crc12Dect.init();496 var c = Crc.init();
497 c.update("1234");497 c.update("1234");
498 c.update("56789");498 c.update("56789");
499 try testing.expectEqual(@as(u12, 0xf5b), c.final());499 try testing.expectEqual(@as(u12, 0xf5b), c.final());
500}500}
501501
502test "CRC-12/GSM" {502test "CRC-12/GSM" {
503 const Crc12Gsm = crc.Crc12Gsm;503 const Crc = crc.@"CRC-12/GSM";
504504
505 try testing.expectEqual(@as(u12, 0xb34), Crc12Gsm.hash("123456789"));505 try testing.expectEqual(@as(u12, 0xb34), Crc.hash("123456789"));
506506
507 var c = Crc12Gsm.init();507 var c = Crc.init();
508 c.update("1234");508 c.update("1234");
509 c.update("56789");509 c.update("56789");
510 try testing.expectEqual(@as(u12, 0xb34), c.final());510 try testing.expectEqual(@as(u12, 0xb34), c.final());
511}511}
512512
513test "CRC-12/UMTS" {513test "CRC-12/UMTS" {
514 const Crc12Umts = crc.Crc12Umts;514 const Crc = crc.@"CRC-12/UMTS";
515515
516 try testing.expectEqual(@as(u12, 0xdaf), Crc12Umts.hash("123456789"));516 try testing.expectEqual(@as(u12, 0xdaf), Crc.hash("123456789"));
517517
518 var c = Crc12Umts.init();518 var c = Crc.init();
519 c.update("1234");519 c.update("1234");
520 c.update("56789");520 c.update("56789");
521 try testing.expectEqual(@as(u12, 0xdaf), c.final());521 try testing.expectEqual(@as(u12, 0xdaf), c.final());
522}522}
523523
524test "CRC-13/BBC" {524test "CRC-13/BBC" {
525 const Crc13Bbc = crc.Crc13Bbc;525 const Crc = crc.@"CRC-13/BBC";
526526
527 try testing.expectEqual(@as(u13, 0x04fa), Crc13Bbc.hash("123456789"));527 try testing.expectEqual(@as(u13, 0x04fa), Crc.hash("123456789"));
528528
529 var c = Crc13Bbc.init();529 var c = Crc.init();
530 c.update("1234");530 c.update("1234");
531 c.update("56789");531 c.update("56789");
532 try testing.expectEqual(@as(u13, 0x04fa), c.final());532 try testing.expectEqual(@as(u13, 0x04fa), c.final());
533}533}
534534
535test "CRC-14/DARC" {535test "CRC-14/DARC" {
536 const Crc14Darc = crc.Crc14Darc;536 const Crc = crc.@"CRC-14/DARC";
537537
538 try testing.expectEqual(@as(u14, 0x082d), Crc14Darc.hash("123456789"));538 try testing.expectEqual(@as(u14, 0x082d), Crc.hash("123456789"));
539539
540 var c = Crc14Darc.init();540 var c = Crc.init();
541 c.update("1234");541 c.update("1234");
542 c.update("56789");542 c.update("56789");
543 try testing.expectEqual(@as(u14, 0x082d), c.final());543 try testing.expectEqual(@as(u14, 0x082d), c.final());
544}544}
545545
546test "CRC-14/GSM" {546test "CRC-14/GSM" {
547 const Crc14Gsm = crc.Crc14Gsm;547 const Crc = crc.@"CRC-14/GSM";
548548
549 try testing.expectEqual(@as(u14, 0x30ae), Crc14Gsm.hash("123456789"));549 try testing.expectEqual(@as(u14, 0x30ae), Crc.hash("123456789"));
550550
551 var c = Crc14Gsm.init();551 var c = Crc.init();
552 c.update("1234");552 c.update("1234");
553 c.update("56789");553 c.update("56789");
554 try testing.expectEqual(@as(u14, 0x30ae), c.final());554 try testing.expectEqual(@as(u14, 0x30ae), c.final());
555}555}
556556
557test "CRC-15/CAN" {557test "CRC-15/CAN" {
558 const Crc15Can = crc.Crc15Can;558 const Crc = crc.@"CRC-15/CAN";
559559
560 try testing.expectEqual(@as(u15, 0x059e), Crc15Can.hash("123456789"));560 try testing.expectEqual(@as(u15, 0x059e), Crc.hash("123456789"));
561561
562 var c = Crc15Can.init();562 var c = Crc.init();
563 c.update("1234");563 c.update("1234");
564 c.update("56789");564 c.update("56789");
565 try testing.expectEqual(@as(u15, 0x059e), c.final());565 try testing.expectEqual(@as(u15, 0x059e), c.final());
566}566}
567567
568test "CRC-15/MPT1327" {568test "CRC-15/MPT1327" {
569 const Crc15Mpt1327 = crc.Crc15Mpt1327;569 const Crc = crc.@"CRC-15/MPT1327";
570570
571 try testing.expectEqual(@as(u15, 0x2566), Crc15Mpt1327.hash("123456789"));571 try testing.expectEqual(@as(u15, 0x2566), Crc.hash("123456789"));
572572
573 var c = Crc15Mpt1327.init();573 var c = Crc.init();
574 c.update("1234");574 c.update("1234");
575 c.update("56789");575 c.update("56789");
576 try testing.expectEqual(@as(u15, 0x2566), c.final());576 try testing.expectEqual(@as(u15, 0x2566), c.final());
577}577}
578578
579test "CRC-16/ARC" {579test "CRC-16/ARC" {
580 const Crc16Arc = crc.Crc16Arc;580 const Crc = crc.@"CRC-16/ARC";
581581
582 try testing.expectEqual(@as(u16, 0xbb3d), Crc16Arc.hash("123456789"));582 try testing.expectEqual(@as(u16, 0xbb3d), Crc.hash("123456789"));
583583
584 var c = Crc16Arc.init();584 var c = Crc.init();
585 c.update("1234");585 c.update("1234");
586 c.update("56789");586 c.update("56789");
587 try testing.expectEqual(@as(u16, 0xbb3d), c.final());587 try testing.expectEqual(@as(u16, 0xbb3d), c.final());
588}588}
589589
590test "CRC-16/CDMA2000" {590test "CRC-16/CDMA2000" {
591 const Crc16Cdma2000 = crc.Crc16Cdma2000;591 const Crc = crc.@"CRC-16/CDMA2000";
592592
593 try testing.expectEqual(@as(u16, 0x4c06), Crc16Cdma2000.hash("123456789"));593 try testing.expectEqual(@as(u16, 0x4c06), Crc.hash("123456789"));
594594
595 var c = Crc16Cdma2000.init();595 var c = Crc.init();
596 c.update("1234");596 c.update("1234");
597 c.update("56789");597 c.update("56789");
598 try testing.expectEqual(@as(u16, 0x4c06), c.final());598 try testing.expectEqual(@as(u16, 0x4c06), c.final());
599}599}
600600
601test "CRC-16/CMS" {601test "CRC-16/CMS" {
602 const Crc16Cms = crc.Crc16Cms;602 const Crc = crc.@"CRC-16/CMS";
603603
604 try testing.expectEqual(@as(u16, 0xaee7), Crc16Cms.hash("123456789"));604 try testing.expectEqual(@as(u16, 0xaee7), Crc.hash("123456789"));
605605
606 var c = Crc16Cms.init();606 var c = Crc.init();
607 c.update("1234");607 c.update("1234");
608 c.update("56789");608 c.update("56789");
609 try testing.expectEqual(@as(u16, 0xaee7), c.final());609 try testing.expectEqual(@as(u16, 0xaee7), c.final());
610}610}
611611
612test "CRC-16/DDS-110" {612test "CRC-16/DDS-110" {
613 const Crc16Dds110 = crc.Crc16Dds110;613 const Crc = crc.@"CRC-16/DDS-110";
614614
615 try testing.expectEqual(@as(u16, 0x9ecf), Crc16Dds110.hash("123456789"));615 try testing.expectEqual(@as(u16, 0x9ecf), Crc.hash("123456789"));
616616
617 var c = Crc16Dds110.init();617 var c = Crc.init();
618 c.update("1234");618 c.update("1234");
619 c.update("56789");619 c.update("56789");
620 try testing.expectEqual(@as(u16, 0x9ecf), c.final());620 try testing.expectEqual(@as(u16, 0x9ecf), c.final());
621}621}
622622
623test "CRC-16/DECT-R" {623test "CRC-16/DECT-R" {
624 const Crc16DectR = crc.Crc16DectR;624 const Crc = crc.@"CRC-16/DECT-R";
625625
626 try testing.expectEqual(@as(u16, 0x007e), Crc16DectR.hash("123456789"));626 try testing.expectEqual(@as(u16, 0x007e), Crc.hash("123456789"));
627627
628 var c = Crc16DectR.init();628 var c = Crc.init();
629 c.update("1234");629 c.update("1234");
630 c.update("56789");630 c.update("56789");
631 try testing.expectEqual(@as(u16, 0x007e), c.final());631 try testing.expectEqual(@as(u16, 0x007e), c.final());
632}632}
633633
634test "CRC-16/DECT-X" {634test "CRC-16/DECT-X" {
635 const Crc16DectX = crc.Crc16DectX;635 const Crc = crc.@"CRC-16/DECT-X";
636636
637 try testing.expectEqual(@as(u16, 0x007f), Crc16DectX.hash("123456789"));637 try testing.expectEqual(@as(u16, 0x007f), Crc.hash("123456789"));
638638
639 var c = Crc16DectX.init();639 var c = Crc.init();
640 c.update("1234");640 c.update("1234");
641 c.update("56789");641 c.update("56789");
642 try testing.expectEqual(@as(u16, 0x007f), c.final());642 try testing.expectEqual(@as(u16, 0x007f), c.final());
643}643}
644644
645test "CRC-16/DNP" {645test "CRC-16/DNP" {
646 const Crc16Dnp = crc.Crc16Dnp;646 const Crc = crc.@"CRC-16/DNP";
647647
648 try testing.expectEqual(@as(u16, 0xea82), Crc16Dnp.hash("123456789"));648 try testing.expectEqual(@as(u16, 0xea82), Crc.hash("123456789"));
649649
650 var c = Crc16Dnp.init();650 var c = Crc.init();
651 c.update("1234");651 c.update("1234");
652 c.update("56789");652 c.update("56789");
653 try testing.expectEqual(@as(u16, 0xea82), c.final());653 try testing.expectEqual(@as(u16, 0xea82), c.final());
654}654}
655655
656test "CRC-16/EN-13757" {656test "CRC-16/EN-13757" {
657 const Crc16En13757 = crc.Crc16En13757;657 const Crc = crc.@"CRC-16/EN-13757";
658658
659 try testing.expectEqual(@as(u16, 0xc2b7), Crc16En13757.hash("123456789"));659 try testing.expectEqual(@as(u16, 0xc2b7), Crc.hash("123456789"));
660660
661 var c = Crc16En13757.init();661 var c = Crc.init();
662 c.update("1234");662 c.update("1234");
663 c.update("56789");663 c.update("56789");
664 try testing.expectEqual(@as(u16, 0xc2b7), c.final());664 try testing.expectEqual(@as(u16, 0xc2b7), c.final());
665}665}
666666
667test "CRC-16/GENIBUS" {667test "CRC-16/GENIBUS" {
668 const Crc16Genibus = crc.Crc16Genibus;668 const Crc = crc.@"CRC-16/GENIBUS";
669669
670 try testing.expectEqual(@as(u16, 0xd64e), Crc16Genibus.hash("123456789"));670 try testing.expectEqual(@as(u16, 0xd64e), Crc.hash("123456789"));
671671
672 var c = Crc16Genibus.init();672 var c = Crc.init();
673 c.update("1234");673 c.update("1234");
674 c.update("56789");674 c.update("56789");
675 try testing.expectEqual(@as(u16, 0xd64e), c.final());675 try testing.expectEqual(@as(u16, 0xd64e), c.final());
676}676}
677677
678test "CRC-16/GSM" {678test "CRC-16/GSM" {
679 const Crc16Gsm = crc.Crc16Gsm;679 const Crc = crc.@"CRC-16/GSM";
680680
681 try testing.expectEqual(@as(u16, 0xce3c), Crc16Gsm.hash("123456789"));681 try testing.expectEqual(@as(u16, 0xce3c), Crc.hash("123456789"));
682682
683 var c = Crc16Gsm.init();683 var c = Crc.init();
684 c.update("1234");684 c.update("1234");
685 c.update("56789");685 c.update("56789");
686 try testing.expectEqual(@as(u16, 0xce3c), c.final());686 try testing.expectEqual(@as(u16, 0xce3c), c.final());
687}687}
688688
689test "CRC-16/IBM-3740" {689test "CRC-16/IBM-3740" {
690 const Crc16Ibm3740 = crc.Crc16Ibm3740;690 const Crc = crc.@"CRC-16/IBM-3740";
691691
692 try testing.expectEqual(@as(u16, 0x29b1), Crc16Ibm3740.hash("123456789"));692 try testing.expectEqual(@as(u16, 0x29b1), Crc.hash("123456789"));
693693
694 var c = Crc16Ibm3740.init();694 var c = Crc.init();
695 c.update("1234");695 c.update("1234");
696 c.update("56789");696 c.update("56789");
697 try testing.expectEqual(@as(u16, 0x29b1), c.final());697 try testing.expectEqual(@as(u16, 0x29b1), c.final());
698}698}
699699
700test "CRC-16/IBM-SDLC" {700test "CRC-16/IBM-SDLC" {
701 const Crc16IbmSdlc = crc.Crc16IbmSdlc;701 const Crc = crc.@"CRC-16/IBM-SDLC";
702702
703 try testing.expectEqual(@as(u16, 0x906e), Crc16IbmSdlc.hash("123456789"));703 try testing.expectEqual(@as(u16, 0x906e), Crc.hash("123456789"));
704704
705 var c = Crc16IbmSdlc.init();705 var c = Crc.init();
706 c.update("1234");706 c.update("1234");
707 c.update("56789");707 c.update("56789");
708 try testing.expectEqual(@as(u16, 0x906e), c.final());708 try testing.expectEqual(@as(u16, 0x906e), c.final());
709}709}
710710
711test "CRC-16/ISO-IEC-14443-3-A" {711test "CRC-16/ISO-IEC-14443-3-A" {
712 const Crc16IsoIec144433A = crc.Crc16IsoIec144433A;712 const Crc = crc.@"CRC-16/ISO-IEC-14443-3-A";
713713
714 try testing.expectEqual(@as(u16, 0xbf05), Crc16IsoIec144433A.hash("123456789"));714 try testing.expectEqual(@as(u16, 0xbf05), Crc.hash("123456789"));
715715
716 var c = Crc16IsoIec144433A.init();716 var c = Crc.init();
717 c.update("1234");717 c.update("1234");
718 c.update("56789");718 c.update("56789");
719 try testing.expectEqual(@as(u16, 0xbf05), c.final());719 try testing.expectEqual(@as(u16, 0xbf05), c.final());
720}720}
721721
722test "CRC-16/KERMIT" {722test "CRC-16/KERMIT" {
723 const Crc16Kermit = crc.Crc16Kermit;723 const Crc = crc.@"CRC-16/KERMIT";
724724
725 try testing.expectEqual(@as(u16, 0x2189), Crc16Kermit.hash("123456789"));725 try testing.expectEqual(@as(u16, 0x2189), Crc.hash("123456789"));
726726
727 var c = Crc16Kermit.init();727 var c = Crc.init();
728 c.update("1234");728 c.update("1234");
729 c.update("56789");729 c.update("56789");
730 try testing.expectEqual(@as(u16, 0x2189), c.final());730 try testing.expectEqual(@as(u16, 0x2189), c.final());
731}731}
732732
733test "CRC-16/LJ1200" {733test "CRC-16/LJ1200" {
734 const Crc16Lj1200 = crc.Crc16Lj1200;734 const Crc = crc.@"CRC-16/LJ1200";
735735
736 try testing.expectEqual(@as(u16, 0xbdf4), Crc16Lj1200.hash("123456789"));736 try testing.expectEqual(@as(u16, 0xbdf4), Crc.hash("123456789"));
737737
738 var c = Crc16Lj1200.init();738 var c = Crc.init();
739 c.update("1234");739 c.update("1234");
740 c.update("56789");740 c.update("56789");
741 try testing.expectEqual(@as(u16, 0xbdf4), c.final());741 try testing.expectEqual(@as(u16, 0xbdf4), c.final());
742}742}
743743
744test "CRC-16/M17" {744test "CRC-16/M17" {
745 const Crc16M17 = crc.Crc16M17;745 const Crc = crc.@"CRC-16/M17";
746746
747 try testing.expectEqual(@as(u16, 0x772b), Crc16M17.hash("123456789"));747 try testing.expectEqual(@as(u16, 0x772b), Crc.hash("123456789"));
748748
749 var c = Crc16M17.init();749 var c = Crc.init();
750 c.update("1234");750 c.update("1234");
751 c.update("56789");751 c.update("56789");
752 try testing.expectEqual(@as(u16, 0x772b), c.final());752 try testing.expectEqual(@as(u16, 0x772b), c.final());
753}753}
754754
755test "CRC-16/MAXIM-DOW" {755test "CRC-16/MAXIM-DOW" {
756 const Crc16MaximDow = crc.Crc16MaximDow;756 const Crc = crc.@"CRC-16/MAXIM-DOW";
757757
758 try testing.expectEqual(@as(u16, 0x44c2), Crc16MaximDow.hash("123456789"));758 try testing.expectEqual(@as(u16, 0x44c2), Crc.hash("123456789"));
759759
760 var c = Crc16MaximDow.init();760 var c = Crc.init();
761 c.update("1234");761 c.update("1234");
762 c.update("56789");762 c.update("56789");
763 try testing.expectEqual(@as(u16, 0x44c2), c.final());763 try testing.expectEqual(@as(u16, 0x44c2), c.final());
764}764}
765765
766test "CRC-16/MCRF4XX" {766test "CRC-16/MCRF4XX" {
767 const Crc16Mcrf4xx = crc.Crc16Mcrf4xx;767 const Crc = crc.@"CRC-16/MCRF4XX";
768768
769 try testing.expectEqual(@as(u16, 0x6f91), Crc16Mcrf4xx.hash("123456789"));769 try testing.expectEqual(@as(u16, 0x6f91), Crc.hash("123456789"));
770770
771 var c = Crc16Mcrf4xx.init();771 var c = Crc.init();
772 c.update("1234");772 c.update("1234");
773 c.update("56789");773 c.update("56789");
774 try testing.expectEqual(@as(u16, 0x6f91), c.final());774 try testing.expectEqual(@as(u16, 0x6f91), c.final());
775}775}
776776
777test "CRC-16/MODBUS" {777test "CRC-16/MODBUS" {
778 const Crc16Modbus = crc.Crc16Modbus;778 const Crc = crc.@"CRC-16/MODBUS";
779779
780 try testing.expectEqual(@as(u16, 0x4b37), Crc16Modbus.hash("123456789"));780 try testing.expectEqual(@as(u16, 0x4b37), Crc.hash("123456789"));
781781
782 var c = Crc16Modbus.init();782 var c = Crc.init();
783 c.update("1234");783 c.update("1234");
784 c.update("56789");784 c.update("56789");
785 try testing.expectEqual(@as(u16, 0x4b37), c.final());785 try testing.expectEqual(@as(u16, 0x4b37), c.final());
786}786}
787787
788test "CRC-16/NRSC-5" {788test "CRC-16/NRSC-5" {
789 const Crc16Nrsc5 = crc.Crc16Nrsc5;789 const Crc = crc.@"CRC-16/NRSC-5";
790790
791 try testing.expectEqual(@as(u16, 0xa066), Crc16Nrsc5.hash("123456789"));791 try testing.expectEqual(@as(u16, 0xa066), Crc.hash("123456789"));
792792
793 var c = Crc16Nrsc5.init();793 var c = Crc.init();
794 c.update("1234");794 c.update("1234");
795 c.update("56789");795 c.update("56789");
796 try testing.expectEqual(@as(u16, 0xa066), c.final());796 try testing.expectEqual(@as(u16, 0xa066), c.final());
797}797}
798798
799test "CRC-16/OPENSAFETY-A" {799test "CRC-16/OPENSAFETY-A" {
800 const Crc16OpensafetyA = crc.Crc16OpensafetyA;800 const Crc = crc.@"CRC-16/OPENSAFETY-A";
801801
802 try testing.expectEqual(@as(u16, 0x5d38), Crc16OpensafetyA.hash("123456789"));802 try testing.expectEqual(@as(u16, 0x5d38), Crc.hash("123456789"));
803803
804 var c = Crc16OpensafetyA.init();804 var c = Crc.init();
805 c.update("1234");805 c.update("1234");
806 c.update("56789");806 c.update("56789");
807 try testing.expectEqual(@as(u16, 0x5d38), c.final());807 try testing.expectEqual(@as(u16, 0x5d38), c.final());
808}808}
809809
810test "CRC-16/OPENSAFETY-B" {810test "CRC-16/OPENSAFETY-B" {
811 const Crc16OpensafetyB = crc.Crc16OpensafetyB;811 const Crc = crc.@"CRC-16/OPENSAFETY-B";
812812
813 try testing.expectEqual(@as(u16, 0x20fe), Crc16OpensafetyB.hash("123456789"));813 try testing.expectEqual(@as(u16, 0x20fe), Crc.hash("123456789"));
814814
815 var c = Crc16OpensafetyB.init();815 var c = Crc.init();
816 c.update("1234");816 c.update("1234");
817 c.update("56789");817 c.update("56789");
818 try testing.expectEqual(@as(u16, 0x20fe), c.final());818 try testing.expectEqual(@as(u16, 0x20fe), c.final());
819}819}
820820
821test "CRC-16/PROFIBUS" {821test "CRC-16/PROFIBUS" {
822 const Crc16Profibus = crc.Crc16Profibus;822 const Crc = crc.@"CRC-16/PROFIBUS";
823823
824 try testing.expectEqual(@as(u16, 0xa819), Crc16Profibus.hash("123456789"));824 try testing.expectEqual(@as(u16, 0xa819), Crc.hash("123456789"));
825825
826 var c = Crc16Profibus.init();826 var c = Crc.init();
827 c.update("1234");827 c.update("1234");
828 c.update("56789");828 c.update("56789");
829 try testing.expectEqual(@as(u16, 0xa819), c.final());829 try testing.expectEqual(@as(u16, 0xa819), c.final());
830}830}
831831
832test "CRC-16/RIELLO" {832test "CRC-16/RIELLO" {
833 const Crc16Riello = crc.Crc16Riello;833 const Crc = crc.@"CRC-16/RIELLO";
834834
835 try testing.expectEqual(@as(u16, 0x63d0), Crc16Riello.hash("123456789"));835 try testing.expectEqual(@as(u16, 0x63d0), Crc.hash("123456789"));
836836
837 var c = Crc16Riello.init();837 var c = Crc.init();
838 c.update("1234");838 c.update("1234");
839 c.update("56789");839 c.update("56789");
840 try testing.expectEqual(@as(u16, 0x63d0), c.final());840 try testing.expectEqual(@as(u16, 0x63d0), c.final());
841}841}
842842
843test "CRC-16/SPI-FUJITSU" {843test "CRC-16/SPI-FUJITSU" {
844 const Crc16SpiFujitsu = crc.Crc16SpiFujitsu;844 const Crc = crc.@"CRC-16/SPI-FUJITSU";
845845
846 try testing.expectEqual(@as(u16, 0xe5cc), Crc16SpiFujitsu.hash("123456789"));846 try testing.expectEqual(@as(u16, 0xe5cc), Crc.hash("123456789"));
847847
848 var c = Crc16SpiFujitsu.init();848 var c = Crc.init();
849 c.update("1234");849 c.update("1234");
850 c.update("56789");850 c.update("56789");
851 try testing.expectEqual(@as(u16, 0xe5cc), c.final());851 try testing.expectEqual(@as(u16, 0xe5cc), c.final());
852}852}
853853
854test "CRC-16/T10-DIF" {854test "CRC-16/T10-DIF" {
855 const Crc16T10Dif = crc.Crc16T10Dif;855 const Crc = crc.@"CRC-16/T10-DIF";
856856
857 try testing.expectEqual(@as(u16, 0xd0db), Crc16T10Dif.hash("123456789"));857 try testing.expectEqual(@as(u16, 0xd0db), Crc.hash("123456789"));
858858
859 var c = Crc16T10Dif.init();859 var c = Crc.init();
860 c.update("1234");860 c.update("1234");
861 c.update("56789");861 c.update("56789");
862 try testing.expectEqual(@as(u16, 0xd0db), c.final());862 try testing.expectEqual(@as(u16, 0xd0db), c.final());
863}863}
864864
865test "CRC-16/TELEDISK" {865test "CRC-16/TELEDISK" {
866 const Crc16Teledisk = crc.Crc16Teledisk;866 const Crc = crc.@"CRC-16/TELEDISK";
867867
868 try testing.expectEqual(@as(u16, 0x0fb3), Crc16Teledisk.hash("123456789"));868 try testing.expectEqual(@as(u16, 0x0fb3), Crc.hash("123456789"));
869869
870 var c = Crc16Teledisk.init();870 var c = Crc.init();
871 c.update("1234");871 c.update("1234");
872 c.update("56789");872 c.update("56789");
873 try testing.expectEqual(@as(u16, 0x0fb3), c.final());873 try testing.expectEqual(@as(u16, 0x0fb3), c.final());
874}874}
875875
876test "CRC-16/TMS37157" {876test "CRC-16/TMS37157" {
877 const Crc16Tms37157 = crc.Crc16Tms37157;877 const Crc = crc.@"CRC-16/TMS37157";
878878
879 try testing.expectEqual(@as(u16, 0x26b1), Crc16Tms37157.hash("123456789"));879 try testing.expectEqual(@as(u16, 0x26b1), Crc.hash("123456789"));
880880
881 var c = Crc16Tms37157.init();881 var c = Crc.init();
882 c.update("1234");882 c.update("1234");
883 c.update("56789");883 c.update("56789");
884 try testing.expectEqual(@as(u16, 0x26b1), c.final());884 try testing.expectEqual(@as(u16, 0x26b1), c.final());
885}885}
886886
887test "CRC-16/UMTS" {887test "CRC-16/UMTS" {
888 const Crc16Umts = crc.Crc16Umts;888 const Crc = crc.@"CRC-16/UMTS";
889889
890 try testing.expectEqual(@as(u16, 0xfee8), Crc16Umts.hash("123456789"));890 try testing.expectEqual(@as(u16, 0xfee8), Crc.hash("123456789"));
891891
892 var c = Crc16Umts.init();892 var c = Crc.init();
893 c.update("1234");893 c.update("1234");
894 c.update("56789");894 c.update("56789");
895 try testing.expectEqual(@as(u16, 0xfee8), c.final());895 try testing.expectEqual(@as(u16, 0xfee8), c.final());
896}896}
897897
898test "CRC-16/USB" {898test "CRC-16/USB" {
899 const Crc16Usb = crc.Crc16Usb;899 const Crc = crc.@"CRC-16/USB";
900900
901 try testing.expectEqual(@as(u16, 0xb4c8), Crc16Usb.hash("123456789"));901 try testing.expectEqual(@as(u16, 0xb4c8), Crc.hash("123456789"));
902902
903 var c = Crc16Usb.init();903 var c = Crc.init();
904 c.update("1234");904 c.update("1234");
905 c.update("56789");905 c.update("56789");
906 try testing.expectEqual(@as(u16, 0xb4c8), c.final());906 try testing.expectEqual(@as(u16, 0xb4c8), c.final());
907}907}
908908
909test "CRC-16/XMODEM" {909test "CRC-16/XMODEM" {
910 const Crc16Xmodem = crc.Crc16Xmodem;910 const Crc = crc.@"CRC-16/XMODEM";
911911
912 try testing.expectEqual(@as(u16, 0x31c3), Crc16Xmodem.hash("123456789"));912 try testing.expectEqual(@as(u16, 0x31c3), Crc.hash("123456789"));
913913
914 var c = Crc16Xmodem.init();914 var c = Crc.init();
915 c.update("1234");915 c.update("1234");
916 c.update("56789");916 c.update("56789");
917 try testing.expectEqual(@as(u16, 0x31c3), c.final());917 try testing.expectEqual(@as(u16, 0x31c3), c.final());
918}918}
919919
920test "CRC-17/CAN-FD" {920test "CRC-17/CAN-FD" {
921 const Crc17CanFd = crc.Crc17CanFd;921 const Crc = crc.@"CRC-17/CAN-FD";
922922
923 try testing.expectEqual(@as(u17, 0x04f03), Crc17CanFd.hash("123456789"));923 try testing.expectEqual(@as(u17, 0x04f03), Crc.hash("123456789"));
924924
925 var c = Crc17CanFd.init();925 var c = Crc.init();
926 c.update("1234");926 c.update("1234");
927 c.update("56789");927 c.update("56789");
928 try testing.expectEqual(@as(u17, 0x04f03), c.final());928 try testing.expectEqual(@as(u17, 0x04f03), c.final());
929}929}
930930
931test "CRC-21/CAN-FD" {931test "CRC-21/CAN-FD" {
932 const Crc21CanFd = crc.Crc21CanFd;932 const Crc = crc.@"CRC-21/CAN-FD";
933933
934 try testing.expectEqual(@as(u21, 0x0ed841), Crc21CanFd.hash("123456789"));934 try testing.expectEqual(@as(u21, 0x0ed841), Crc.hash("123456789"));
935935
936 var c = Crc21CanFd.init();936 var c = Crc.init();
937 c.update("1234");937 c.update("1234");
938 c.update("56789");938 c.update("56789");
939 try testing.expectEqual(@as(u21, 0x0ed841), c.final());939 try testing.expectEqual(@as(u21, 0x0ed841), c.final());
940}940}
941941
942test "CRC-24/BLE" {942test "CRC-24/BLE" {
943 const Crc24Ble = crc.Crc24Ble;943 const Crc = crc.@"CRC-24/BLE";
944944
945 try testing.expectEqual(@as(u24, 0xc25a56), Crc24Ble.hash("123456789"));945 try testing.expectEqual(@as(u24, 0xc25a56), Crc.hash("123456789"));
946946
947 var c = Crc24Ble.init();947 var c = Crc.init();
948 c.update("1234");948 c.update("1234");
949 c.update("56789");949 c.update("56789");
950 try testing.expectEqual(@as(u24, 0xc25a56), c.final());950 try testing.expectEqual(@as(u24, 0xc25a56), c.final());
951}951}
952952
953test "CRC-24/FLEXRAY-A" {953test "CRC-24/FLEXRAY-A" {
954 const Crc24FlexrayA = crc.Crc24FlexrayA;954 const Crc = crc.@"CRC-24/FLEXRAY-A";
955955
956 try testing.expectEqual(@as(u24, 0x7979bd), Crc24FlexrayA.hash("123456789"));956 try testing.expectEqual(@as(u24, 0x7979bd), Crc.hash("123456789"));
957957
958 var c = Crc24FlexrayA.init();958 var c = Crc.init();
959 c.update("1234");959 c.update("1234");
960 c.update("56789");960 c.update("56789");
961 try testing.expectEqual(@as(u24, 0x7979bd), c.final());961 try testing.expectEqual(@as(u24, 0x7979bd), c.final());
962}962}
963963
964test "CRC-24/FLEXRAY-B" {964test "CRC-24/FLEXRAY-B" {
965 const Crc24FlexrayB = crc.Crc24FlexrayB;965 const Crc = crc.@"CRC-24/FLEXRAY-B";
966966
967 try testing.expectEqual(@as(u24, 0x1f23b8), Crc24FlexrayB.hash("123456789"));967 try testing.expectEqual(@as(u24, 0x1f23b8), Crc.hash("123456789"));
968968
969 var c = Crc24FlexrayB.init();969 var c = Crc.init();
970 c.update("1234");970 c.update("1234");
971 c.update("56789");971 c.update("56789");
972 try testing.expectEqual(@as(u24, 0x1f23b8), c.final());972 try testing.expectEqual(@as(u24, 0x1f23b8), c.final());
973}973}
974974
975test "CRC-24/INTERLAKEN" {975test "CRC-24/INTERLAKEN" {
976 const Crc24Interlaken = crc.Crc24Interlaken;976 const Crc = crc.@"CRC-24/INTERLAKEN";
977977
978 try testing.expectEqual(@as(u24, 0xb4f3e6), Crc24Interlaken.hash("123456789"));978 try testing.expectEqual(@as(u24, 0xb4f3e6), Crc.hash("123456789"));
979979
980 var c = Crc24Interlaken.init();980 var c = Crc.init();
981 c.update("1234");981 c.update("1234");
982 c.update("56789");982 c.update("56789");
983 try testing.expectEqual(@as(u24, 0xb4f3e6), c.final());983 try testing.expectEqual(@as(u24, 0xb4f3e6), c.final());
984}984}
985985
986test "CRC-24/LTE-A" {986test "CRC-24/LTE-A" {
987 const Crc24LteA = crc.Crc24LteA;987 const Crc = crc.@"CRC-24/LTE-A";
988988
989 try testing.expectEqual(@as(u24, 0xcde703), Crc24LteA.hash("123456789"));989 try testing.expectEqual(@as(u24, 0xcde703), Crc.hash("123456789"));
990990
991 var c = Crc24LteA.init();991 var c = Crc.init();
992 c.update("1234");992 c.update("1234");
993 c.update("56789");993 c.update("56789");
994 try testing.expectEqual(@as(u24, 0xcde703), c.final());994 try testing.expectEqual(@as(u24, 0xcde703), c.final());
995}995}
996996
997test "CRC-24/LTE-B" {997test "CRC-24/LTE-B" {
998 const Crc24LteB = crc.Crc24LteB;998 const Crc = crc.@"CRC-24/LTE-B";
999999
1000 try testing.expectEqual(@as(u24, 0x23ef52), Crc24LteB.hash("123456789"));1000 try testing.expectEqual(@as(u24, 0x23ef52), Crc.hash("123456789"));
10011001
1002 var c = Crc24LteB.init();1002 var c = Crc.init();
1003 c.update("1234");1003 c.update("1234");
1004 c.update("56789");1004 c.update("56789");
1005 try testing.expectEqual(@as(u24, 0x23ef52), c.final());1005 try testing.expectEqual(@as(u24, 0x23ef52), c.final());
1006}1006}
10071007
1008test "CRC-24/OPENPGP" {1008test "CRC-24/OPENPGP" {
1009 const Crc24Openpgp = crc.Crc24Openpgp;1009 const Crc = crc.@"CRC-24/OPENPGP";
10101010
1011 try testing.expectEqual(@as(u24, 0x21cf02), Crc24Openpgp.hash("123456789"));1011 try testing.expectEqual(@as(u24, 0x21cf02), Crc.hash("123456789"));
10121012
1013 var c = Crc24Openpgp.init();1013 var c = Crc.init();
1014 c.update("1234");1014 c.update("1234");
1015 c.update("56789");1015 c.update("56789");
1016 try testing.expectEqual(@as(u24, 0x21cf02), c.final());1016 try testing.expectEqual(@as(u24, 0x21cf02), c.final());
1017}1017}
10181018
1019test "CRC-24/OS-9" {1019test "CRC-24/OS-9" {
1020 const Crc24Os9 = crc.Crc24Os9;1020 const Crc = crc.@"CRC-24/OS-9";
10211021
1022 try testing.expectEqual(@as(u24, 0x200fa5), Crc24Os9.hash("123456789"));1022 try testing.expectEqual(@as(u24, 0x200fa5), Crc.hash("123456789"));
10231023
1024 var c = Crc24Os9.init();1024 var c = Crc.init();
1025 c.update("1234");1025 c.update("1234");
1026 c.update("56789");1026 c.update("56789");
1027 try testing.expectEqual(@as(u24, 0x200fa5), c.final());1027 try testing.expectEqual(@as(u24, 0x200fa5), c.final());
1028}1028}
10291029
1030test "CRC-30/CDMA" {1030test "CRC-30/CDMA" {
1031 const Crc30Cdma = crc.Crc30Cdma;1031 const Crc = crc.@"CRC-30/CDMA";
10321032
1033 try testing.expectEqual(@as(u30, 0x04c34abf), Crc30Cdma.hash("123456789"));1033 try testing.expectEqual(@as(u30, 0x04c34abf), Crc.hash("123456789"));
10341034
1035 var c = Crc30Cdma.init();1035 var c = Crc.init();
1036 c.update("1234");1036 c.update("1234");
1037 c.update("56789");1037 c.update("56789");
1038 try testing.expectEqual(@as(u30, 0x04c34abf), c.final());1038 try testing.expectEqual(@as(u30, 0x04c34abf), c.final());
1039}1039}
10401040
1041test "CRC-31/PHILIPS" {1041test "CRC-31/PHILIPS" {
1042 const Crc31Philips = crc.Crc31Philips;1042 const Crc = crc.@"CRC-31/PHILIPS";
10431043
1044 try testing.expectEqual(@as(u31, 0x0ce9e46c), Crc31Philips.hash("123456789"));1044 try testing.expectEqual(@as(u31, 0x0ce9e46c), Crc.hash("123456789"));
10451045
1046 var c = Crc31Philips.init();1046 var c = Crc.init();
1047 c.update("1234");1047 c.update("1234");
1048 c.update("56789");1048 c.update("56789");
1049 try testing.expectEqual(@as(u31, 0x0ce9e46c), c.final());1049 try testing.expectEqual(@as(u31, 0x0ce9e46c), c.final());
1050}1050}
10511051
1052test "CRC-32/AIXM" {1052test "CRC-32/AIXM" {
1053 const Crc32Aixm = crc.Crc32Aixm;1053 const Crc = crc.@"CRC-32/AIXM";
10541054
1055 try testing.expectEqual(@as(u32, 0x3010bf7f), Crc32Aixm.hash("123456789"));1055 try testing.expectEqual(@as(u32, 0x3010bf7f), Crc.hash("123456789"));
10561056
1057 var c = Crc32Aixm.init();1057 var c = Crc.init();
1058 c.update("1234");1058 c.update("1234");
1059 c.update("56789");1059 c.update("56789");
1060 try testing.expectEqual(@as(u32, 0x3010bf7f), c.final());1060 try testing.expectEqual(@as(u32, 0x3010bf7f), c.final());
1061}1061}
10621062
1063test "CRC-32/AUTOSAR" {1063test "CRC-32/AUTOSAR" {
1064 const Crc32Autosar = crc.Crc32Autosar;1064 const Crc = crc.@"CRC-32/AUTOSAR";
10651065
1066 try testing.expectEqual(@as(u32, 0x1697d06a), Crc32Autosar.hash("123456789"));1066 try testing.expectEqual(@as(u32, 0x1697d06a), Crc.hash("123456789"));
10671067
1068 var c = Crc32Autosar.init();1068 var c = Crc.init();
1069 c.update("1234");1069 c.update("1234");
1070 c.update("56789");1070 c.update("56789");
1071 try testing.expectEqual(@as(u32, 0x1697d06a), c.final());1071 try testing.expectEqual(@as(u32, 0x1697d06a), c.final());
1072}1072}
10731073
1074test "CRC-32/BASE91-D" {1074test "CRC-32/BASE91-D" {
1075 const Crc32Base91D = crc.Crc32Base91D;1075 const Crc = crc.@"CRC-32/BASE91-D";
10761076
1077 try testing.expectEqual(@as(u32, 0x87315576), Crc32Base91D.hash("123456789"));1077 try testing.expectEqual(@as(u32, 0x87315576), Crc.hash("123456789"));
10781078
1079 var c = Crc32Base91D.init();1079 var c = Crc.init();
1080 c.update("1234");1080 c.update("1234");
1081 c.update("56789");1081 c.update("56789");
1082 try testing.expectEqual(@as(u32, 0x87315576), c.final());1082 try testing.expectEqual(@as(u32, 0x87315576), c.final());
1083}1083}
10841084
1085test "CRC-32/BZIP2" {1085test "CRC-32/BZIP2" {
1086 const Crc32Bzip2 = crc.Crc32Bzip2;1086 const Crc = crc.@"CRC-32/BZIP2";
10871087
1088 try testing.expectEqual(@as(u32, 0xfc891918), Crc32Bzip2.hash("123456789"));1088 try testing.expectEqual(@as(u32, 0xfc891918), Crc.hash("123456789"));
10891089
1090 var c = Crc32Bzip2.init();1090 var c = Crc.init();
1091 c.update("1234");1091 c.update("1234");
1092 c.update("56789");1092 c.update("56789");
1093 try testing.expectEqual(@as(u32, 0xfc891918), c.final());1093 try testing.expectEqual(@as(u32, 0xfc891918), c.final());
1094}1094}
10951095
1096test "CRC-32/CD-ROM-EDC" {1096test "CRC-32/CD-ROM-EDC" {
1097 const Crc32CdRomEdc = crc.Crc32CdRomEdc;1097 const Crc = crc.@"CRC-32/CD-ROM-EDC";
10981098
1099 try testing.expectEqual(@as(u32, 0x6ec2edc4), Crc32CdRomEdc.hash("123456789"));1099 try testing.expectEqual(@as(u32, 0x6ec2edc4), Crc.hash("123456789"));
11001100
1101 var c = Crc32CdRomEdc.init();1101 var c = Crc.init();
1102 c.update("1234");1102 c.update("1234");
1103 c.update("56789");1103 c.update("56789");
1104 try testing.expectEqual(@as(u32, 0x6ec2edc4), c.final());1104 try testing.expectEqual(@as(u32, 0x6ec2edc4), c.final());
1105}1105}
11061106
1107test "CRC-32/CKSUM" {1107test "CRC-32/CKSUM" {
1108 const Crc32Cksum = crc.Crc32Cksum;1108 const Crc = crc.@"CRC-32/CKSUM";
11091109
1110 try testing.expectEqual(@as(u32, 0x765e7680), Crc32Cksum.hash("123456789"));1110 try testing.expectEqual(@as(u32, 0x765e7680), Crc.hash("123456789"));
11111111
1112 var c = Crc32Cksum.init();1112 var c = Crc.init();
1113 c.update("1234");1113 c.update("1234");
1114 c.update("56789");1114 c.update("56789");
1115 try testing.expectEqual(@as(u32, 0x765e7680), c.final());1115 try testing.expectEqual(@as(u32, 0x765e7680), c.final());
1116}1116}
11171117
1118test "CRC-32/ISO-HDLC" {1118test "CRC-32/ISO-HDLC" {
1119 const Crc32IsoHdlc = crc.Crc32IsoHdlc;1119 const Crc = crc.@"CRC-32/ISO-HDLC";
11201120
1121 try testing.expectEqual(@as(u32, 0xcbf43926), Crc32IsoHdlc.hash("123456789"));1121 try testing.expectEqual(@as(u32, 0xcbf43926), Crc.hash("123456789"));
11221122
1123 var c = Crc32IsoHdlc.init();1123 var c = Crc.init();
1124 c.update("1234");1124 c.update("1234");
1125 c.update("56789");1125 c.update("56789");
1126 try testing.expectEqual(@as(u32, 0xcbf43926), c.final());1126 try testing.expectEqual(@as(u32, 0xcbf43926), c.final());
1127}1127}
11281128
1129test "CRC-32/JAMCRC" {1129test "CRC-32/JAMCRC" {
1130 const Crc32Jamcrc = crc.Crc32Jamcrc;1130 const Crc = crc.@"CRC-32/JAMCRC";
11311131
1132 try testing.expectEqual(@as(u32, 0x340bc6d9), Crc32Jamcrc.hash("123456789"));1132 try testing.expectEqual(@as(u32, 0x340bc6d9), Crc.hash("123456789"));
11331133
1134 var c = Crc32Jamcrc.init();1134 var c = Crc.init();
1135 c.update("1234");1135 c.update("1234");
1136 c.update("56789");1136 c.update("56789");
1137 try testing.expectEqual(@as(u32, 0x340bc6d9), c.final());1137 try testing.expectEqual(@as(u32, 0x340bc6d9), c.final());
1138}1138}
11391139
1140test "CRC-32/KOOPMAN" {1140test "CRC-32/KOOPMAN" {
1141 const Crc32Koopman = crc.Crc32Koopman;1141 const Crc = crc.@"CRC-32/KOOPMAN";
11421142
1143 try testing.expectEqual(@as(u32, 0x2d3dd0ae), Crc32Koopman.hash("123456789"));1143 try testing.expectEqual(@as(u32, 0x2d3dd0ae), Crc.hash("123456789"));
11441144
1145 var c = Crc32Koopman.init();1145 var c = Crc.init();
1146 c.update("1234");1146 c.update("1234");
1147 c.update("56789");1147 c.update("56789");
1148 try testing.expectEqual(@as(u32, 0x2d3dd0ae), c.final());1148 try testing.expectEqual(@as(u32, 0x2d3dd0ae), c.final());
1149}1149}
11501150
1151test "CRC-32/MEF" {1151test "CRC-32/MEF" {
1152 const Crc32Mef = crc.Crc32Mef;1152 const Crc = crc.@"CRC-32/MEF";
11531153
1154 try testing.expectEqual(@as(u32, 0xd2c22f51), Crc32Mef.hash("123456789"));1154 try testing.expectEqual(@as(u32, 0xd2c22f51), Crc.hash("123456789"));
11551155
1156 var c = Crc32Mef.init();1156 var c = Crc.init();
1157 c.update("1234");1157 c.update("1234");
1158 c.update("56789");1158 c.update("56789");
1159 try testing.expectEqual(@as(u32, 0xd2c22f51), c.final());1159 try testing.expectEqual(@as(u32, 0xd2c22f51), c.final());
1160}1160}
11611161
1162test "CRC-32/MPEG-2" {1162test "CRC-32/MPEG-2" {
1163 const Crc32Mpeg2 = crc.Crc32Mpeg2;1163 const Crc = crc.@"CRC-32/MPEG-2";
11641164
1165 try testing.expectEqual(@as(u32, 0x0376e6e7), Crc32Mpeg2.hash("123456789"));1165 try testing.expectEqual(@as(u32, 0x0376e6e7), Crc.hash("123456789"));
11661166
1167 var c = Crc32Mpeg2.init();1167 var c = Crc.init();
1168 c.update("1234");1168 c.update("1234");
1169 c.update("56789");1169 c.update("56789");
1170 try testing.expectEqual(@as(u32, 0x0376e6e7), c.final());1170 try testing.expectEqual(@as(u32, 0x0376e6e7), c.final());
1171}1171}
11721172
1173test "CRC-32/XFER" {1173test "CRC-32/XFER" {
1174 const Crc32Xfer = crc.Crc32Xfer;1174 const Crc = crc.@"CRC-32/XFER";
11751175
1176 try testing.expectEqual(@as(u32, 0xbd0be338), Crc32Xfer.hash("123456789"));1176 try testing.expectEqual(@as(u32, 0xbd0be338), Crc.hash("123456789"));
11771177
1178 var c = Crc32Xfer.init();1178 var c = Crc.init();
1179 c.update("1234");1179 c.update("1234");
1180 c.update("56789");1180 c.update("56789");
1181 try testing.expectEqual(@as(u32, 0xbd0be338), c.final());1181 try testing.expectEqual(@as(u32, 0xbd0be338), c.final());
1182}1182}
11831183
1184test "CRC-40/GSM" {1184test "CRC-40/GSM" {
1185 const Crc40Gsm = crc.Crc40Gsm;1185 const Crc = crc.@"CRC-40/GSM";
11861186
1187 try testing.expectEqual(@as(u40, 0xd4164fc646), Crc40Gsm.hash("123456789"));1187 try testing.expectEqual(@as(u40, 0xd4164fc646), Crc.hash("123456789"));
11881188
1189 var c = Crc40Gsm.init();1189 var c = Crc.init();
1190 c.update("1234");1190 c.update("1234");
1191 c.update("56789");1191 c.update("56789");
1192 try testing.expectEqual(@as(u40, 0xd4164fc646), c.final());1192 try testing.expectEqual(@as(u40, 0xd4164fc646), c.final());
1193}1193}
11941194
1195test "CRC-64/ECMA-182" {1195test "CRC-64/ECMA-182" {
1196 const Crc64Ecma182 = crc.Crc64Ecma182;1196 const Crc = crc.@"CRC-64/ECMA-182";
11971197
1198 try testing.expectEqual(@as(u64, 0x6c40df5f0b497347), Crc64Ecma182.hash("123456789"));1198 try testing.expectEqual(@as(u64, 0x6c40df5f0b497347), Crc.hash("123456789"));
11991199
1200 var c = Crc64Ecma182.init();1200 var c = Crc.init();
1201 c.update("1234");1201 c.update("1234");
1202 c.update("56789");1202 c.update("56789");
1203 try testing.expectEqual(@as(u64, 0x6c40df5f0b497347), c.final());1203 try testing.expectEqual(@as(u64, 0x6c40df5f0b497347), c.final());
1204}1204}
12051205
1206test "CRC-64/GO-ISO" {1206test "CRC-64/GO-ISO" {
1207 const Crc64GoIso = crc.Crc64GoIso;1207 const Crc = crc.@"CRC-64/GO-ISO";
12081208
1209 try testing.expectEqual(@as(u64, 0xb90956c775a41001), Crc64GoIso.hash("123456789"));1209 try testing.expectEqual(@as(u64, 0xb90956c775a41001), Crc.hash("123456789"));
12101210
1211 var c = Crc64GoIso.init();1211 var c = Crc.init();
1212 c.update("1234");1212 c.update("1234");
1213 c.update("56789");1213 c.update("56789");
1214 try testing.expectEqual(@as(u64, 0xb90956c775a41001), c.final());1214 try testing.expectEqual(@as(u64, 0xb90956c775a41001), c.final());
1215}1215}
12161216
1217test "CRC-64/MS" {1217test "CRC-64/MS" {
1218 const Crc64Ms = crc.Crc64Ms;1218 const Crc = crc.@"CRC-64/MS";
12191219
1220 try testing.expectEqual(@as(u64, 0x75d4b74f024eceea), Crc64Ms.hash("123456789"));1220 try testing.expectEqual(@as(u64, 0x75d4b74f024eceea), Crc.hash("123456789"));
12211221
1222 var c = Crc64Ms.init();1222 var c = Crc.init();
1223 c.update("1234");1223 c.update("1234");
1224 c.update("56789");1224 c.update("56789");
1225 try testing.expectEqual(@as(u64, 0x75d4b74f024eceea), c.final());1225 try testing.expectEqual(@as(u64, 0x75d4b74f024eceea), c.final());
1226}1226}
12271227
1228test "CRC-64/REDIS" {1228test "CRC-64/REDIS" {
1229 const Crc64Redis = crc.Crc64Redis;1229 const Crc = crc.@"CRC-64/REDIS";
12301230
1231 try testing.expectEqual(@as(u64, 0xe9c6d914c4b8d9ca), Crc64Redis.hash("123456789"));1231 try testing.expectEqual(@as(u64, 0xe9c6d914c4b8d9ca), Crc.hash("123456789"));
12321232
1233 var c = Crc64Redis.init();1233 var c = Crc.init();
1234 c.update("1234");1234 c.update("1234");
1235 c.update("56789");1235 c.update("56789");
1236 try testing.expectEqual(@as(u64, 0xe9c6d914c4b8d9ca), c.final());1236 try testing.expectEqual(@as(u64, 0xe9c6d914c4b8d9ca), c.final());
1237}1237}
12381238
1239test "CRC-64/WE" {1239test "CRC-64/WE" {
1240 const Crc64We = crc.Crc64We;1240 const Crc = crc.@"CRC-64/WE";
12411241
1242 try testing.expectEqual(@as(u64, 0x62ec59e3f1a4f00a), Crc64We.hash("123456789"));1242 try testing.expectEqual(@as(u64, 0x62ec59e3f1a4f00a), Crc.hash("123456789"));
12431243
1244 var c = Crc64We.init();1244 var c = Crc.init();
1245 c.update("1234");1245 c.update("1234");
1246 c.update("56789");1246 c.update("56789");
1247 try testing.expectEqual(@as(u64, 0x62ec59e3f1a4f00a), c.final());1247 try testing.expectEqual(@as(u64, 0x62ec59e3f1a4f00a), c.final());
1248}1248}
12491249
1250test "CRC-64/XZ" {1250test "CRC-64/XZ" {
1251 const Crc64Xz = crc.Crc64Xz;1251 const Crc = crc.@"CRC-64/XZ";
12521252
1253 try testing.expectEqual(@as(u64, 0x995dc9bbdf1939fa), Crc64Xz.hash("123456789"));1253 try testing.expectEqual(@as(u64, 0x995dc9bbdf1939fa), Crc.hash("123456789"));
12541254
1255 var c = Crc64Xz.init();1255 var c = Crc.init();
1256 c.update("1234");1256 c.update("1234");
1257 c.update("56789");1257 c.update("56789");
1258 try testing.expectEqual(@as(u64, 0x995dc9bbdf1939fa), c.final());1258 try testing.expectEqual(@as(u64, 0x995dc9bbdf1939fa), c.final());
1259}1259}
12601260
1261test "CRC-82/DARC" {1261test "CRC-82/DARC" {
1262 const Crc82Darc = crc.Crc82Darc;1262 const Crc = crc.@"CRC-82/DARC";
12631263
1264 try testing.expectEqual(@as(u82, 0x09ea83f625023801fd612), Crc82Darc.hash("123456789"));1264 try testing.expectEqual(@as(u82, 0x09ea83f625023801fd612), Crc.hash("123456789"));
12651265
1266 var c = Crc82Darc.init();1266 var c = Crc.init();
1267 c.update("1234");1267 c.update("1234");
1268 c.update("56789");1268 c.update("56789");
1269 try testing.expectEqual(@as(u82, 0x09ea83f625023801fd612), c.final());1269 try testing.expectEqual(@as(u82, 0x09ea83f625023801fd612), c.final());
src/link/Coff.zig+2-1
...@@ -7,6 +7,7 @@ const std = @import("std");...@@ -7,6 +7,7 @@ const std = @import("std");
7const Io = std.Io;7const Io = std.Io;
8const assert = std.debug.assert;8const assert = std.debug.assert;
9const log = std.log.scoped(.link);9const log = std.log.scoped(.link);
10const Crc32 = std.hash.crc.@"CRC-32/JAMCRC";
1011
11const codegen = @import("../codegen.zig");12const codegen = @import("../codegen.zig");
12const Compilation = @import("../Compilation.zig");13const Compilation = @import("../Compilation.zig");
...@@ -4599,7 +4600,7 @@ fn loadObject(...@@ -4599,7 +4600,7 @@ fn loadObject(
4599 const sym = si.get(coff);4600 const sym = si.get(coff);
4600 const existing_crc = switch (coff.getNode(sym.ni)) {4601 const existing_crc = switch (coff.getNode(sym.ni)) {
4601 .input_section => |isi| isi.inputSection(coff).crc,4602 .input_section => |isi| isi.inputSection(coff).crc,
4602 else => std.hash.crc.Crc32Jamcrc.hash(sym.ni.sliceConst(&coff.mf)),4603 else => Crc32.hash(sym.ni.sliceConst(&coff.mf)),
4603 };4604 };
46044605
4605 if (existing_crc == section.comdat_crc) {4606 if (existing_crc == section.comdat_crc) {
tools/crc/catalog.txt+1-2
...@@ -97,8 +97,7 @@ width=32 poly=0xa833982b init=0xffffffff refin=true refout=true xorout=0xff...@@ -97,8 +97,7 @@ width=32 poly=0xa833982b init=0xffffffff refin=true refout=true xorout=0xff
97width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0xffffffff check=0xfc891918 residue=0xc704dd7b name="CRC-32/BZIP2"97width=32 poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0xffffffff check=0xfc891918 residue=0xc704dd7b name="CRC-32/BZIP2"
98width=32 poly=0x8001801b init=0x00000000 refin=true refout=true xorout=0x00000000 check=0x6ec2edc4 residue=0x00000000 name="CRC-32/CD-ROM-EDC"98width=32 poly=0x8001801b init=0x00000000 refin=true refout=true xorout=0x00000000 check=0x6ec2edc4 residue=0x00000000 name="CRC-32/CD-ROM-EDC"
99width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680 residue=0xc704dd7b name="CRC-32/CKSUM"99width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680 residue=0xc704dd7b name="CRC-32/CKSUM"
100# CRC-32C implementation is defined manually, since it has an accelerated variant.100width=32 poly=0x1edc6f41 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xe3069283 residue=0xb798b438 name="CRC-32/ISCSI"
101# width=32 poly=0x1edc6f41 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xe3069283 residue=0xb798b438 name="CRC-32/ISCSI"
102width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 residue=0xdebb20e3 name="CRC-32/ISO-HDLC"101width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926 residue=0xdebb20e3 name="CRC-32/ISO-HDLC"
103width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0x00000000 check=0x340bc6d9 residue=0x00000000 name="CRC-32/JAMCRC"102width=32 poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0x00000000 check=0x340bc6d9 residue=0x00000000 name="CRC-32/JAMCRC"
104width=32 poly=0x741b8cd7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0x2d3dd0ae residue=0x00000000 name="CRC-32/KOOPMAN"103width=32 poly=0x741b8cd7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0x2d3dd0ae residue=0x00000000 name="CRC-32/KOOPMAN"
tools/update_crc_catalog.zig+6-32
...@@ -2,7 +2,6 @@ const std = @import("std");...@@ -2,7 +2,6 @@ const std = @import("std");
2const Io = std.Io;2const Io = std.Io;
3const Dir = std.Io.Dir;3const Dir = std.Io.Dir;
4const mem = std.mem;4const mem = std.mem;
5const ascii = std.ascii;
65
7const catalog_txt = @embedFile("crc/catalog.txt");6const catalog_txt = @embedFile("crc/catalog.txt");
87
...@@ -148,34 +147,9 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)...@@ -148,34 +147,9 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)
148 }147 }
149 }148 }
150149
151 const snakecase = try ascii.allocLowerString(arena, name);
152 defer arena.free(snakecase);
153
154 _ = mem.replace(u8, snakecase, "-", "_", snakecase);
155 _ = mem.replace(u8, snakecase, "/", "_", snakecase);
156
157 var buf = try std.array_list.Managed(u8).initCapacity(arena, snakecase.len);
158 defer buf.deinit();
159
160 var prev: u8 = 0;
161 for (snakecase, 0..) |c, i| {
162 if (c == '_') {
163 // do nothing
164 } else if (i == 0) {
165 buf.appendAssumeCapacity(ascii.toUpper(c));
166 } else if (prev == '_') {
167 buf.appendAssumeCapacity(ascii.toUpper(c));
168 } else {
169 buf.appendAssumeCapacity(c);
170 }
171 prev = c;
172 }
173
174 const camelcase = buf.items;
175
176 try code_writer.print(150 try code_writer.print(
177 \\151 \\
178 \\pub const {s} = Generic(u{s}, .{{152 \\pub const {f} = Generic(u{s}, .{{
179 \\ .polynomial = {s},153 \\ .polynomial = {s},
180 \\ .initial = {s},154 \\ .initial = {s},
181 \\ .reflect_input = {s},155 \\ .reflect_input = {s},
...@@ -183,22 +157,22 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)...@@ -183,22 +157,22 @@ fn @"i like cheese"(arena: std.mem.Allocator, io: Io, args: []const []const u8)
183 \\ .xor_output = {s},157 \\ .xor_output = {s},
184 \\}});158 \\}});
185 \\159 \\
186 , .{ camelcase, width, poly, init, refin, refout, xorout });160 , .{ std.zig.fmtId(name), width, poly, init, refin, refout, xorout });
187161
188 try test_writer.print(162 try test_writer.print(
189 \\163 \\
190 \\test "{0s}" {{164 \\test "{0s}" {{
191 \\ const {1s} = crc.{1s};165 \\ const Crc = crc.{1f};
192 \\166 \\
193 \\ try testing.expectEqual(@as(u{2s}, {3s}), {1s}.hash("123456789"));167 \\ try testing.expectEqual(@as(u{2s}, {3s}), Crc.hash("123456789"));
194 \\168 \\
195 \\ var c = {1s}.init();169 \\ var c = Crc.init();
196 \\ c.update("1234");170 \\ c.update("1234");
197 \\ c.update("56789");171 \\ c.update("56789");
198 \\ try testing.expectEqual(@as(u{2s}, {3s}), c.final());172 \\ try testing.expectEqual(@as(u{2s}, {3s}), c.final());
199 \\}}173 \\}}
200 \\174 \\
201 , .{ name, camelcase, width, check });175 , .{ name, std.zig.fmtId(name), width, check });
202 }176 }
203177
204 try code_writer.writeAll(178 try code_writer.writeAll(