| ... | @@ -0,0 +1,1463 @@ |
| 1 | //! This file is auto-generated by tools/update_crc_catalog.sh. |
| 2 | |
| 3 | const std = @import("../../std.zig"); |
| 4 | const testing = std.testing; |
| 5 | const crc = @import("../crc.zig"); |
| 6 | const Algorithm = crc.Algorithm; |
| 7 | const Crc = crc.Crc; |
| 8 | |
| 9 | const crc_3_gsm: Algorithm(u3) = .{ .poly = 0x3, .init = 0x0, .refin = false, .refout = false, .xorout = 0x7, .check = 0x4, .residue = 0x2 }; |
| 10 | |
| 11 | pub const Crc3Gsm = Crc(u3, crc_3_gsm); |
| 12 | |
| 13 | test "CRC-3/GSM" { |
| 14 | try testing.expectEqual(crc_3_gsm.check, Crc3Gsm.hash("123456789")); |
| 15 | |
| 16 | var c = Crc3Gsm.init(); |
| 17 | c.update("1234"); |
| 18 | c.update("56789"); |
| 19 | try testing.expectEqual(crc_3_gsm.check, c.final()); |
| 20 | } |
| 21 | |
| 22 | const crc_3_rohc: Algorithm(u3) = .{ .poly = 0x3, .init = 0x7, .refin = true, .refout = true, .xorout = 0x0, .check = 0x6, .residue = 0x0 }; |
| 23 | |
| 24 | pub const Crc3Rohc = Crc(u3, crc_3_rohc); |
| 25 | |
| 26 | test "CRC-3/ROHC" { |
| 27 | try testing.expectEqual(crc_3_rohc.check, Crc3Rohc.hash("123456789")); |
| 28 | |
| 29 | var c = Crc3Rohc.init(); |
| 30 | c.update("1234"); |
| 31 | c.update("56789"); |
| 32 | try testing.expectEqual(crc_3_rohc.check, c.final()); |
| 33 | } |
| 34 | |
| 35 | const crc_4_g_704: Algorithm(u4) = .{ .poly = 0x3, .init = 0x0, .refin = true, .refout = true, .xorout = 0x0, .check = 0x7, .residue = 0x0 }; |
| 36 | |
| 37 | pub const Crc4G704 = Crc(u4, crc_4_g_704); |
| 38 | |
| 39 | test "CRC-4/G-704" { |
| 40 | try testing.expectEqual(crc_4_g_704.check, Crc4G704.hash("123456789")); |
| 41 | |
| 42 | var c = Crc4G704.init(); |
| 43 | c.update("1234"); |
| 44 | c.update("56789"); |
| 45 | try testing.expectEqual(crc_4_g_704.check, c.final()); |
| 46 | } |
| 47 | |
| 48 | const crc_4_interlaken: Algorithm(u4) = .{ .poly = 0x3, .init = 0xf, .refin = false, .refout = false, .xorout = 0xf, .check = 0xb, .residue = 0x2 }; |
| 49 | |
| 50 | pub const Crc4Interlaken = Crc(u4, crc_4_interlaken); |
| 51 | |
| 52 | test "CRC-4/INTERLAKEN" { |
| 53 | try testing.expectEqual(crc_4_interlaken.check, Crc4Interlaken.hash("123456789")); |
| 54 | |
| 55 | var c = Crc4Interlaken.init(); |
| 56 | c.update("1234"); |
| 57 | c.update("56789"); |
| 58 | try testing.expectEqual(crc_4_interlaken.check, c.final()); |
| 59 | } |
| 60 | |
| 61 | const crc_5_epc_c1g2: Algorithm(u5) = .{ .poly = 0x09, .init = 0x09, .refin = false, .refout = false, .xorout = 0x00, .check = 0x00, .residue = 0x00 }; |
| 62 | |
| 63 | pub const Crc5EpcC1g2 = Crc(u5, crc_5_epc_c1g2); |
| 64 | |
| 65 | test "CRC-5/EPC-C1G2" { |
| 66 | try testing.expectEqual(crc_5_epc_c1g2.check, Crc5EpcC1g2.hash("123456789")); |
| 67 | |
| 68 | var c = Crc5EpcC1g2.init(); |
| 69 | c.update("1234"); |
| 70 | c.update("56789"); |
| 71 | try testing.expectEqual(crc_5_epc_c1g2.check, c.final()); |
| 72 | } |
| 73 | |
| 74 | const crc_5_g_704: Algorithm(u5) = .{ .poly = 0x15, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x07, .residue = 0x00 }; |
| 75 | |
| 76 | pub const Crc5G704 = Crc(u5, crc_5_g_704); |
| 77 | |
| 78 | test "CRC-5/G-704" { |
| 79 | try testing.expectEqual(crc_5_g_704.check, Crc5G704.hash("123456789")); |
| 80 | |
| 81 | var c = Crc5G704.init(); |
| 82 | c.update("1234"); |
| 83 | c.update("56789"); |
| 84 | try testing.expectEqual(crc_5_g_704.check, c.final()); |
| 85 | } |
| 86 | |
| 87 | const crc_5_usb: Algorithm(u5) = .{ .poly = 0x05, .init = 0x1f, .refin = true, .refout = true, .xorout = 0x1f, .check = 0x19, .residue = 0x06 }; |
| 88 | |
| 89 | pub const Crc5Usb = Crc(u5, crc_5_usb); |
| 90 | |
| 91 | test "CRC-5/USB" { |
| 92 | try testing.expectEqual(crc_5_usb.check, Crc5Usb.hash("123456789")); |
| 93 | |
| 94 | var c = Crc5Usb.init(); |
| 95 | c.update("1234"); |
| 96 | c.update("56789"); |
| 97 | try testing.expectEqual(crc_5_usb.check, c.final()); |
| 98 | } |
| 99 | |
| 100 | const crc_6_cdma2000_a: Algorithm(u6) = .{ .poly = 0x27, .init = 0x3f, .refin = false, .refout = false, .xorout = 0x00, .check = 0x0d, .residue = 0x00 }; |
| 101 | |
| 102 | pub const Crc6Cdma2000A = Crc(u6, crc_6_cdma2000_a); |
| 103 | |
| 104 | test "CRC-6/CDMA2000-A" { |
| 105 | try testing.expectEqual(crc_6_cdma2000_a.check, Crc6Cdma2000A.hash("123456789")); |
| 106 | |
| 107 | var c = Crc6Cdma2000A.init(); |
| 108 | c.update("1234"); |
| 109 | c.update("56789"); |
| 110 | try testing.expectEqual(crc_6_cdma2000_a.check, c.final()); |
| 111 | } |
| 112 | |
| 113 | const crc_6_cdma2000_b: Algorithm(u6) = .{ .poly = 0x07, .init = 0x3f, .refin = false, .refout = false, .xorout = 0x00, .check = 0x3b, .residue = 0x00 }; |
| 114 | |
| 115 | pub const Crc6Cdma2000B = Crc(u6, crc_6_cdma2000_b); |
| 116 | |
| 117 | test "CRC-6/CDMA2000-B" { |
| 118 | try testing.expectEqual(crc_6_cdma2000_b.check, Crc6Cdma2000B.hash("123456789")); |
| 119 | |
| 120 | var c = Crc6Cdma2000B.init(); |
| 121 | c.update("1234"); |
| 122 | c.update("56789"); |
| 123 | try testing.expectEqual(crc_6_cdma2000_b.check, c.final()); |
| 124 | } |
| 125 | |
| 126 | const crc_6_darc: Algorithm(u6) = .{ .poly = 0x19, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x26, .residue = 0x00 }; |
| 127 | |
| 128 | pub const Crc6Darc = Crc(u6, crc_6_darc); |
| 129 | |
| 130 | test "CRC-6/DARC" { |
| 131 | try testing.expectEqual(crc_6_darc.check, Crc6Darc.hash("123456789")); |
| 132 | |
| 133 | var c = Crc6Darc.init(); |
| 134 | c.update("1234"); |
| 135 | c.update("56789"); |
| 136 | try testing.expectEqual(crc_6_darc.check, c.final()); |
| 137 | } |
| 138 | |
| 139 | const crc_6_g_704: Algorithm(u6) = .{ .poly = 0x03, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x06, .residue = 0x00 }; |
| 140 | |
| 141 | pub const Crc6G704 = Crc(u6, crc_6_g_704); |
| 142 | |
| 143 | test "CRC-6/G-704" { |
| 144 | try testing.expectEqual(crc_6_g_704.check, Crc6G704.hash("123456789")); |
| 145 | |
| 146 | var c = Crc6G704.init(); |
| 147 | c.update("1234"); |
| 148 | c.update("56789"); |
| 149 | try testing.expectEqual(crc_6_g_704.check, c.final()); |
| 150 | } |
| 151 | |
| 152 | const crc_6_gsm: Algorithm(u6) = .{ .poly = 0x2f, .init = 0x00, .refin = false, .refout = false, .xorout = 0x3f, .check = 0x13, .residue = 0x3a }; |
| 153 | |
| 154 | pub const Crc6Gsm = Crc(u6, crc_6_gsm); |
| 155 | |
| 156 | test "CRC-6/GSM" { |
| 157 | try testing.expectEqual(crc_6_gsm.check, Crc6Gsm.hash("123456789")); |
| 158 | |
| 159 | var c = Crc6Gsm.init(); |
| 160 | c.update("1234"); |
| 161 | c.update("56789"); |
| 162 | try testing.expectEqual(crc_6_gsm.check, c.final()); |
| 163 | } |
| 164 | |
| 165 | const crc_7_mmc: Algorithm(u7) = .{ .poly = 0x09, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x75, .residue = 0x00 }; |
| 166 | |
| 167 | pub const Crc7Mmc = Crc(u7, crc_7_mmc); |
| 168 | |
| 169 | test "CRC-7/MMC" { |
| 170 | try testing.expectEqual(crc_7_mmc.check, Crc7Mmc.hash("123456789")); |
| 171 | |
| 172 | var c = Crc7Mmc.init(); |
| 173 | c.update("1234"); |
| 174 | c.update("56789"); |
| 175 | try testing.expectEqual(crc_7_mmc.check, c.final()); |
| 176 | } |
| 177 | |
| 178 | const crc_7_rohc: Algorithm(u7) = .{ .poly = 0x4f, .init = 0x7f, .refin = true, .refout = true, .xorout = 0x00, .check = 0x53, .residue = 0x00 }; |
| 179 | |
| 180 | pub const Crc7Rohc = Crc(u7, crc_7_rohc); |
| 181 | |
| 182 | test "CRC-7/ROHC" { |
| 183 | try testing.expectEqual(crc_7_rohc.check, Crc7Rohc.hash("123456789")); |
| 184 | |
| 185 | var c = Crc7Rohc.init(); |
| 186 | c.update("1234"); |
| 187 | c.update("56789"); |
| 188 | try testing.expectEqual(crc_7_rohc.check, c.final()); |
| 189 | } |
| 190 | |
| 191 | const crc_7_umts: Algorithm(u7) = .{ .poly = 0x45, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x61, .residue = 0x00 }; |
| 192 | |
| 193 | pub const Crc7Umts = Crc(u7, crc_7_umts); |
| 194 | |
| 195 | test "CRC-7/UMTS" { |
| 196 | try testing.expectEqual(crc_7_umts.check, Crc7Umts.hash("123456789")); |
| 197 | |
| 198 | var c = Crc7Umts.init(); |
| 199 | c.update("1234"); |
| 200 | c.update("56789"); |
| 201 | try testing.expectEqual(crc_7_umts.check, c.final()); |
| 202 | } |
| 203 | |
| 204 | const crc_8_autosar: Algorithm(u8) = .{ .poly = 0x2f, .init = 0xff, .refin = false, .refout = false, .xorout = 0xff, .check = 0xdf, .residue = 0x42 }; |
| 205 | |
| 206 | pub const Crc8Autosar = Crc(u8, crc_8_autosar); |
| 207 | |
| 208 | test "CRC-8/AUTOSAR" { |
| 209 | try testing.expectEqual(crc_8_autosar.check, Crc8Autosar.hash("123456789")); |
| 210 | |
| 211 | var c = Crc8Autosar.init(); |
| 212 | c.update("1234"); |
| 213 | c.update("56789"); |
| 214 | try testing.expectEqual(crc_8_autosar.check, c.final()); |
| 215 | } |
| 216 | |
| 217 | const crc_8_bluetooth: Algorithm(u8) = .{ .poly = 0xa7, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x26, .residue = 0x00 }; |
| 218 | |
| 219 | pub const Crc8Bluetooth = Crc(u8, crc_8_bluetooth); |
| 220 | |
| 221 | test "CRC-8/BLUETOOTH" { |
| 222 | try testing.expectEqual(crc_8_bluetooth.check, Crc8Bluetooth.hash("123456789")); |
| 223 | |
| 224 | var c = Crc8Bluetooth.init(); |
| 225 | c.update("1234"); |
| 226 | c.update("56789"); |
| 227 | try testing.expectEqual(crc_8_bluetooth.check, c.final()); |
| 228 | } |
| 229 | |
| 230 | const crc_8_cdma2000: Algorithm(u8) = .{ .poly = 0x9b, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xda, .residue = 0x00 }; |
| 231 | |
| 232 | pub const Crc8Cdma2000 = Crc(u8, crc_8_cdma2000); |
| 233 | |
| 234 | test "CRC-8/CDMA2000" { |
| 235 | try testing.expectEqual(crc_8_cdma2000.check, Crc8Cdma2000.hash("123456789")); |
| 236 | |
| 237 | var c = Crc8Cdma2000.init(); |
| 238 | c.update("1234"); |
| 239 | c.update("56789"); |
| 240 | try testing.expectEqual(crc_8_cdma2000.check, c.final()); |
| 241 | } |
| 242 | |
| 243 | const crc_8_darc: Algorithm(u8) = .{ .poly = 0x39, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x15, .residue = 0x00 }; |
| 244 | |
| 245 | pub const Crc8Darc = Crc(u8, crc_8_darc); |
| 246 | |
| 247 | test "CRC-8/DARC" { |
| 248 | try testing.expectEqual(crc_8_darc.check, Crc8Darc.hash("123456789")); |
| 249 | |
| 250 | var c = Crc8Darc.init(); |
| 251 | c.update("1234"); |
| 252 | c.update("56789"); |
| 253 | try testing.expectEqual(crc_8_darc.check, c.final()); |
| 254 | } |
| 255 | |
| 256 | const crc_8_dvb_s2: Algorithm(u8) = .{ .poly = 0xd5, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xbc, .residue = 0x00 }; |
| 257 | |
| 258 | pub const Crc8DvbS2 = Crc(u8, crc_8_dvb_s2); |
| 259 | |
| 260 | test "CRC-8/DVB-S2" { |
| 261 | try testing.expectEqual(crc_8_dvb_s2.check, Crc8DvbS2.hash("123456789")); |
| 262 | |
| 263 | var c = Crc8DvbS2.init(); |
| 264 | c.update("1234"); |
| 265 | c.update("56789"); |
| 266 | try testing.expectEqual(crc_8_dvb_s2.check, c.final()); |
| 267 | } |
| 268 | |
| 269 | const crc_8_gsm_a: Algorithm(u8) = .{ .poly = 0x1d, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x37, .residue = 0x00 }; |
| 270 | |
| 271 | pub const Crc8GsmA = Crc(u8, crc_8_gsm_a); |
| 272 | |
| 273 | test "CRC-8/GSM-A" { |
| 274 | try testing.expectEqual(crc_8_gsm_a.check, Crc8GsmA.hash("123456789")); |
| 275 | |
| 276 | var c = Crc8GsmA.init(); |
| 277 | c.update("1234"); |
| 278 | c.update("56789"); |
| 279 | try testing.expectEqual(crc_8_gsm_a.check, c.final()); |
| 280 | } |
| 281 | |
| 282 | const crc_8_gsm_b: Algorithm(u8) = .{ .poly = 0x49, .init = 0x00, .refin = false, .refout = false, .xorout = 0xff, .check = 0x94, .residue = 0x53 }; |
| 283 | |
| 284 | pub const Crc8GsmB = Crc(u8, crc_8_gsm_b); |
| 285 | |
| 286 | test "CRC-8/GSM-B" { |
| 287 | try testing.expectEqual(crc_8_gsm_b.check, Crc8GsmB.hash("123456789")); |
| 288 | |
| 289 | var c = Crc8GsmB.init(); |
| 290 | c.update("1234"); |
| 291 | c.update("56789"); |
| 292 | try testing.expectEqual(crc_8_gsm_b.check, c.final()); |
| 293 | } |
| 294 | |
| 295 | const crc_8_hitag: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xb4, .residue = 0x00 }; |
| 296 | |
| 297 | pub const Crc8Hitag = Crc(u8, crc_8_hitag); |
| 298 | |
| 299 | test "CRC-8/HITAG" { |
| 300 | try testing.expectEqual(crc_8_hitag.check, Crc8Hitag.hash("123456789")); |
| 301 | |
| 302 | var c = Crc8Hitag.init(); |
| 303 | c.update("1234"); |
| 304 | c.update("56789"); |
| 305 | try testing.expectEqual(crc_8_hitag.check, c.final()); |
| 306 | } |
| 307 | |
| 308 | const crc_8_i_432_1: Algorithm(u8) = .{ .poly = 0x07, .init = 0x00, .refin = false, .refout = false, .xorout = 0x55, .check = 0xa1, .residue = 0xac }; |
| 309 | |
| 310 | pub const Crc8I4321 = Crc(u8, crc_8_i_432_1); |
| 311 | |
| 312 | test "CRC-8/I-432-1" { |
| 313 | try testing.expectEqual(crc_8_i_432_1.check, Crc8I4321.hash("123456789")); |
| 314 | |
| 315 | var c = Crc8I4321.init(); |
| 316 | c.update("1234"); |
| 317 | c.update("56789"); |
| 318 | try testing.expectEqual(crc_8_i_432_1.check, c.final()); |
| 319 | } |
| 320 | |
| 321 | const crc_8_i_code: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xfd, .refin = false, .refout = false, .xorout = 0x00, .check = 0x7e, .residue = 0x00 }; |
| 322 | |
| 323 | pub const Crc8ICode = Crc(u8, crc_8_i_code); |
| 324 | |
| 325 | test "CRC-8/I-CODE" { |
| 326 | try testing.expectEqual(crc_8_i_code.check, Crc8ICode.hash("123456789")); |
| 327 | |
| 328 | var c = Crc8ICode.init(); |
| 329 | c.update("1234"); |
| 330 | c.update("56789"); |
| 331 | try testing.expectEqual(crc_8_i_code.check, c.final()); |
| 332 | } |
| 333 | |
| 334 | const crc_8_lte: Algorithm(u8) = .{ .poly = 0x9b, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xea, .residue = 0x00 }; |
| 335 | |
| 336 | pub const Crc8Lte = Crc(u8, crc_8_lte); |
| 337 | |
| 338 | test "CRC-8/LTE" { |
| 339 | try testing.expectEqual(crc_8_lte.check, Crc8Lte.hash("123456789")); |
| 340 | |
| 341 | var c = Crc8Lte.init(); |
| 342 | c.update("1234"); |
| 343 | c.update("56789"); |
| 344 | try testing.expectEqual(crc_8_lte.check, c.final()); |
| 345 | } |
| 346 | |
| 347 | const crc_8_maxim_dow: Algorithm(u8) = .{ .poly = 0x31, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0xa1, .residue = 0x00 }; |
| 348 | |
| 349 | pub const Crc8MaximDow = Crc(u8, crc_8_maxim_dow); |
| 350 | |
| 351 | test "CRC-8/MAXIM-DOW" { |
| 352 | try testing.expectEqual(crc_8_maxim_dow.check, Crc8MaximDow.hash("123456789")); |
| 353 | |
| 354 | var c = Crc8MaximDow.init(); |
| 355 | c.update("1234"); |
| 356 | c.update("56789"); |
| 357 | try testing.expectEqual(crc_8_maxim_dow.check, c.final()); |
| 358 | } |
| 359 | |
| 360 | const crc_8_mifare_mad: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xc7, .refin = false, .refout = false, .xorout = 0x00, .check = 0x99, .residue = 0x00 }; |
| 361 | |
| 362 | pub const Crc8MifareMad = Crc(u8, crc_8_mifare_mad); |
| 363 | |
| 364 | test "CRC-8/MIFARE-MAD" { |
| 365 | try testing.expectEqual(crc_8_mifare_mad.check, Crc8MifareMad.hash("123456789")); |
| 366 | |
| 367 | var c = Crc8MifareMad.init(); |
| 368 | c.update("1234"); |
| 369 | c.update("56789"); |
| 370 | try testing.expectEqual(crc_8_mifare_mad.check, c.final()); |
| 371 | } |
| 372 | |
| 373 | const crc_8_nrsc_5: Algorithm(u8) = .{ .poly = 0x31, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xf7, .residue = 0x00 }; |
| 374 | |
| 375 | pub const Crc8Nrsc5 = Crc(u8, crc_8_nrsc_5); |
| 376 | |
| 377 | test "CRC-8/NRSC-5" { |
| 378 | try testing.expectEqual(crc_8_nrsc_5.check, Crc8Nrsc5.hash("123456789")); |
| 379 | |
| 380 | var c = Crc8Nrsc5.init(); |
| 381 | c.update("1234"); |
| 382 | c.update("56789"); |
| 383 | try testing.expectEqual(crc_8_nrsc_5.check, c.final()); |
| 384 | } |
| 385 | |
| 386 | const crc_8_opensafety: Algorithm(u8) = .{ .poly = 0x2f, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x3e, .residue = 0x00 }; |
| 387 | |
| 388 | pub const Crc8Opensafety = Crc(u8, crc_8_opensafety); |
| 389 | |
| 390 | test "CRC-8/OPENSAFETY" { |
| 391 | try testing.expectEqual(crc_8_opensafety.check, Crc8Opensafety.hash("123456789")); |
| 392 | |
| 393 | var c = Crc8Opensafety.init(); |
| 394 | c.update("1234"); |
| 395 | c.update("56789"); |
| 396 | try testing.expectEqual(crc_8_opensafety.check, c.final()); |
| 397 | } |
| 398 | |
| 399 | const crc_8_rohc: Algorithm(u8) = .{ .poly = 0x07, .init = 0xff, .refin = true, .refout = true, .xorout = 0x00, .check = 0xd0, .residue = 0x00 }; |
| 400 | |
| 401 | pub const Crc8Rohc = Crc(u8, crc_8_rohc); |
| 402 | |
| 403 | test "CRC-8/ROHC" { |
| 404 | try testing.expectEqual(crc_8_rohc.check, Crc8Rohc.hash("123456789")); |
| 405 | |
| 406 | var c = Crc8Rohc.init(); |
| 407 | c.update("1234"); |
| 408 | c.update("56789"); |
| 409 | try testing.expectEqual(crc_8_rohc.check, c.final()); |
| 410 | } |
| 411 | |
| 412 | const crc_8_sae_j1850: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = false, .refout = false, .xorout = 0xff, .check = 0x4b, .residue = 0xc4 }; |
| 413 | |
| 414 | pub const Crc8SaeJ1850 = Crc(u8, crc_8_sae_j1850); |
| 415 | |
| 416 | test "CRC-8/SAE-J1850" { |
| 417 | try testing.expectEqual(crc_8_sae_j1850.check, Crc8SaeJ1850.hash("123456789")); |
| 418 | |
| 419 | var c = Crc8SaeJ1850.init(); |
| 420 | c.update("1234"); |
| 421 | c.update("56789"); |
| 422 | try testing.expectEqual(crc_8_sae_j1850.check, c.final()); |
| 423 | } |
| 424 | |
| 425 | const crc_8_smbus: Algorithm(u8) = .{ .poly = 0x07, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xf4, .residue = 0x00 }; |
| 426 | |
| 427 | pub const Crc8Smbus = Crc(u8, crc_8_smbus); |
| 428 | |
| 429 | test "CRC-8/SMBUS" { |
| 430 | try testing.expectEqual(crc_8_smbus.check, Crc8Smbus.hash("123456789")); |
| 431 | |
| 432 | var c = Crc8Smbus.init(); |
| 433 | c.update("1234"); |
| 434 | c.update("56789"); |
| 435 | try testing.expectEqual(crc_8_smbus.check, c.final()); |
| 436 | } |
| 437 | |
| 438 | const crc_8_tech_3250: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = true, .refout = true, .xorout = 0x00, .check = 0x97, .residue = 0x00 }; |
| 439 | |
| 440 | pub const Crc8Tech3250 = Crc(u8, crc_8_tech_3250); |
| 441 | |
| 442 | test "CRC-8/TECH-3250" { |
| 443 | try testing.expectEqual(crc_8_tech_3250.check, Crc8Tech3250.hash("123456789")); |
| 444 | |
| 445 | var c = Crc8Tech3250.init(); |
| 446 | c.update("1234"); |
| 447 | c.update("56789"); |
| 448 | try testing.expectEqual(crc_8_tech_3250.check, c.final()); |
| 449 | } |
| 450 | |
| 451 | const crc_8_wcdma: Algorithm(u8) = .{ .poly = 0x9b, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x25, .residue = 0x00 }; |
| 452 | |
| 453 | pub const Crc8Wcdma = Crc(u8, crc_8_wcdma); |
| 454 | |
| 455 | test "CRC-8/WCDMA" { |
| 456 | try testing.expectEqual(crc_8_wcdma.check, Crc8Wcdma.hash("123456789")); |
| 457 | |
| 458 | var c = Crc8Wcdma.init(); |
| 459 | c.update("1234"); |
| 460 | c.update("56789"); |
| 461 | try testing.expectEqual(crc_8_wcdma.check, c.final()); |
| 462 | } |
| 463 | |
| 464 | const crc_10_atm: Algorithm(u10) = .{ .poly = 0x233, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0x199, .residue = 0x000 }; |
| 465 | |
| 466 | pub const Crc10Atm = Crc(u10, crc_10_atm); |
| 467 | |
| 468 | test "CRC-10/ATM" { |
| 469 | try testing.expectEqual(crc_10_atm.check, Crc10Atm.hash("123456789")); |
| 470 | |
| 471 | var c = Crc10Atm.init(); |
| 472 | c.update("1234"); |
| 473 | c.update("56789"); |
| 474 | try testing.expectEqual(crc_10_atm.check, c.final()); |
| 475 | } |
| 476 | |
| 477 | const crc_10_cdma2000: Algorithm(u10) = .{ .poly = 0x3d9, .init = 0x3ff, .refin = false, .refout = false, .xorout = 0x000, .check = 0x233, .residue = 0x000 }; |
| 478 | |
| 479 | pub const Crc10Cdma2000 = Crc(u10, crc_10_cdma2000); |
| 480 | |
| 481 | test "CRC-10/CDMA2000" { |
| 482 | try testing.expectEqual(crc_10_cdma2000.check, Crc10Cdma2000.hash("123456789")); |
| 483 | |
| 484 | var c = Crc10Cdma2000.init(); |
| 485 | c.update("1234"); |
| 486 | c.update("56789"); |
| 487 | try testing.expectEqual(crc_10_cdma2000.check, c.final()); |
| 488 | } |
| 489 | |
| 490 | const crc_10_gsm: Algorithm(u10) = .{ .poly = 0x175, .init = 0x000, .refin = false, .refout = false, .xorout = 0x3ff, .check = 0x12a, .residue = 0x0c6 }; |
| 491 | |
| 492 | pub const Crc10Gsm = Crc(u10, crc_10_gsm); |
| 493 | |
| 494 | test "CRC-10/GSM" { |
| 495 | try testing.expectEqual(crc_10_gsm.check, Crc10Gsm.hash("123456789")); |
| 496 | |
| 497 | var c = Crc10Gsm.init(); |
| 498 | c.update("1234"); |
| 499 | c.update("56789"); |
| 500 | try testing.expectEqual(crc_10_gsm.check, c.final()); |
| 501 | } |
| 502 | |
| 503 | const crc_11_flexray: Algorithm(u11) = .{ .poly = 0x385, .init = 0x01a, .refin = false, .refout = false, .xorout = 0x000, .check = 0x5a3, .residue = 0x000 }; |
| 504 | |
| 505 | pub const Crc11Flexray = Crc(u11, crc_11_flexray); |
| 506 | |
| 507 | test "CRC-11/FLEXRAY" { |
| 508 | try testing.expectEqual(crc_11_flexray.check, Crc11Flexray.hash("123456789")); |
| 509 | |
| 510 | var c = Crc11Flexray.init(); |
| 511 | c.update("1234"); |
| 512 | c.update("56789"); |
| 513 | try testing.expectEqual(crc_11_flexray.check, c.final()); |
| 514 | } |
| 515 | |
| 516 | const crc_11_umts: Algorithm(u11) = .{ .poly = 0x307, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0x061, .residue = 0x000 }; |
| 517 | |
| 518 | pub const Crc11Umts = Crc(u11, crc_11_umts); |
| 519 | |
| 520 | test "CRC-11/UMTS" { |
| 521 | try testing.expectEqual(crc_11_umts.check, Crc11Umts.hash("123456789")); |
| 522 | |
| 523 | var c = Crc11Umts.init(); |
| 524 | c.update("1234"); |
| 525 | c.update("56789"); |
| 526 | try testing.expectEqual(crc_11_umts.check, c.final()); |
| 527 | } |
| 528 | |
| 529 | const crc_12_cdma2000: Algorithm(u12) = .{ .poly = 0xf13, .init = 0xfff, .refin = false, .refout = false, .xorout = 0x000, .check = 0xd4d, .residue = 0x000 }; |
| 530 | |
| 531 | pub const Crc12Cdma2000 = Crc(u12, crc_12_cdma2000); |
| 532 | |
| 533 | test "CRC-12/CDMA2000" { |
| 534 | try testing.expectEqual(crc_12_cdma2000.check, Crc12Cdma2000.hash("123456789")); |
| 535 | |
| 536 | var c = Crc12Cdma2000.init(); |
| 537 | c.update("1234"); |
| 538 | c.update("56789"); |
| 539 | try testing.expectEqual(crc_12_cdma2000.check, c.final()); |
| 540 | } |
| 541 | |
| 542 | const crc_12_dect: Algorithm(u12) = .{ .poly = 0x80f, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0xf5b, .residue = 0x000 }; |
| 543 | |
| 544 | pub const Crc12Dect = Crc(u12, crc_12_dect); |
| 545 | |
| 546 | test "CRC-12/DECT" { |
| 547 | try testing.expectEqual(crc_12_dect.check, Crc12Dect.hash("123456789")); |
| 548 | |
| 549 | var c = Crc12Dect.init(); |
| 550 | c.update("1234"); |
| 551 | c.update("56789"); |
| 552 | try testing.expectEqual(crc_12_dect.check, c.final()); |
| 553 | } |
| 554 | |
| 555 | const crc_12_gsm: Algorithm(u12) = .{ .poly = 0xd31, .init = 0x000, .refin = false, .refout = false, .xorout = 0xfff, .check = 0xb34, .residue = 0x178 }; |
| 556 | |
| 557 | pub const Crc12Gsm = Crc(u12, crc_12_gsm); |
| 558 | |
| 559 | test "CRC-12/GSM" { |
| 560 | try testing.expectEqual(crc_12_gsm.check, Crc12Gsm.hash("123456789")); |
| 561 | |
| 562 | var c = Crc12Gsm.init(); |
| 563 | c.update("1234"); |
| 564 | c.update("56789"); |
| 565 | try testing.expectEqual(crc_12_gsm.check, c.final()); |
| 566 | } |
| 567 | |
| 568 | const crc_12_umts: Algorithm(u12) = .{ .poly = 0x80f, .init = 0x000, .refin = false, .refout = true, .xorout = 0x000, .check = 0xdaf, .residue = 0x000 }; |
| 569 | |
| 570 | pub const Crc12Umts = Crc(u12, crc_12_umts); |
| 571 | |
| 572 | test "CRC-12/UMTS" { |
| 573 | try testing.expectEqual(crc_12_umts.check, Crc12Umts.hash("123456789")); |
| 574 | |
| 575 | var c = Crc12Umts.init(); |
| 576 | c.update("1234"); |
| 577 | c.update("56789"); |
| 578 | try testing.expectEqual(crc_12_umts.check, c.final()); |
| 579 | } |
| 580 | |
| 581 | const crc_13_bbc: Algorithm(u13) = .{ .poly = 0x1cf5, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x04fa, .residue = 0x0000 }; |
| 582 | |
| 583 | pub const Crc13Bbc = Crc(u13, crc_13_bbc); |
| 584 | |
| 585 | test "CRC-13/BBC" { |
| 586 | try testing.expectEqual(crc_13_bbc.check, Crc13Bbc.hash("123456789")); |
| 587 | |
| 588 | var c = Crc13Bbc.init(); |
| 589 | c.update("1234"); |
| 590 | c.update("56789"); |
| 591 | try testing.expectEqual(crc_13_bbc.check, c.final()); |
| 592 | } |
| 593 | |
| 594 | const crc_14_darc: Algorithm(u14) = .{ .poly = 0x0805, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x082d, .residue = 0x0000 }; |
| 595 | |
| 596 | pub const Crc14Darc = Crc(u14, crc_14_darc); |
| 597 | |
| 598 | test "CRC-14/DARC" { |
| 599 | try testing.expectEqual(crc_14_darc.check, Crc14Darc.hash("123456789")); |
| 600 | |
| 601 | var c = Crc14Darc.init(); |
| 602 | c.update("1234"); |
| 603 | c.update("56789"); |
| 604 | try testing.expectEqual(crc_14_darc.check, c.final()); |
| 605 | } |
| 606 | |
| 607 | const crc_14_gsm: Algorithm(u14) = .{ .poly = 0x202d, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x3fff, .check = 0x30ae, .residue = 0x031e }; |
| 608 | |
| 609 | pub const Crc14Gsm = Crc(u14, crc_14_gsm); |
| 610 | |
| 611 | test "CRC-14/GSM" { |
| 612 | try testing.expectEqual(crc_14_gsm.check, Crc14Gsm.hash("123456789")); |
| 613 | |
| 614 | var c = Crc14Gsm.init(); |
| 615 | c.update("1234"); |
| 616 | c.update("56789"); |
| 617 | try testing.expectEqual(crc_14_gsm.check, c.final()); |
| 618 | } |
| 619 | |
| 620 | const crc_15_can: Algorithm(u15) = .{ .poly = 0x4599, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x059e, .residue = 0x0000 }; |
| 621 | |
| 622 | pub const Crc15Can = Crc(u15, crc_15_can); |
| 623 | |
| 624 | test "CRC-15/CAN" { |
| 625 | try testing.expectEqual(crc_15_can.check, Crc15Can.hash("123456789")); |
| 626 | |
| 627 | var c = Crc15Can.init(); |
| 628 | c.update("1234"); |
| 629 | c.update("56789"); |
| 630 | try testing.expectEqual(crc_15_can.check, c.final()); |
| 631 | } |
| 632 | |
| 633 | const crc_15_mpt1327: Algorithm(u15) = .{ .poly = 0x6815, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0001, .check = 0x2566, .residue = 0x6815 }; |
| 634 | |
| 635 | pub const Crc15Mpt1327 = Crc(u15, crc_15_mpt1327); |
| 636 | |
| 637 | test "CRC-15/MPT1327" { |
| 638 | try testing.expectEqual(crc_15_mpt1327.check, Crc15Mpt1327.hash("123456789")); |
| 639 | |
| 640 | var c = Crc15Mpt1327.init(); |
| 641 | c.update("1234"); |
| 642 | c.update("56789"); |
| 643 | try testing.expectEqual(crc_15_mpt1327.check, c.final()); |
| 644 | } |
| 645 | |
| 646 | const crc_16_arc: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xbb3d, .residue = 0x0000 }; |
| 647 | |
| 648 | pub const Crc16Arc = Crc(u16, crc_16_arc); |
| 649 | |
| 650 | test "CRC-16/ARC" { |
| 651 | try testing.expectEqual(crc_16_arc.check, Crc16Arc.hash("123456789")); |
| 652 | |
| 653 | var c = Crc16Arc.init(); |
| 654 | c.update("1234"); |
| 655 | c.update("56789"); |
| 656 | try testing.expectEqual(crc_16_arc.check, c.final()); |
| 657 | } |
| 658 | |
| 659 | const crc_16_cdma2000: Algorithm(u16) = .{ .poly = 0xc867, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x4c06, .residue = 0x0000 }; |
| 660 | |
| 661 | pub const Crc16Cdma2000 = Crc(u16, crc_16_cdma2000); |
| 662 | |
| 663 | test "CRC-16/CDMA2000" { |
| 664 | try testing.expectEqual(crc_16_cdma2000.check, Crc16Cdma2000.hash("123456789")); |
| 665 | |
| 666 | var c = Crc16Cdma2000.init(); |
| 667 | c.update("1234"); |
| 668 | c.update("56789"); |
| 669 | try testing.expectEqual(crc_16_cdma2000.check, c.final()); |
| 670 | } |
| 671 | |
| 672 | const crc_16_cms: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xaee7, .residue = 0x0000 }; |
| 673 | |
| 674 | pub const Crc16Cms = Crc(u16, crc_16_cms); |
| 675 | |
| 676 | test "CRC-16/CMS" { |
| 677 | try testing.expectEqual(crc_16_cms.check, Crc16Cms.hash("123456789")); |
| 678 | |
| 679 | var c = Crc16Cms.init(); |
| 680 | c.update("1234"); |
| 681 | c.update("56789"); |
| 682 | try testing.expectEqual(crc_16_cms.check, c.final()); |
| 683 | } |
| 684 | |
| 685 | const crc_16_dds_110: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x800d, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x9ecf, .residue = 0x0000 }; |
| 686 | |
| 687 | pub const Crc16Dds110 = Crc(u16, crc_16_dds_110); |
| 688 | |
| 689 | test "CRC-16/DDS-110" { |
| 690 | try testing.expectEqual(crc_16_dds_110.check, Crc16Dds110.hash("123456789")); |
| 691 | |
| 692 | var c = Crc16Dds110.init(); |
| 693 | c.update("1234"); |
| 694 | c.update("56789"); |
| 695 | try testing.expectEqual(crc_16_dds_110.check, c.final()); |
| 696 | } |
| 697 | |
| 698 | const crc_16_dect_r: Algorithm(u16) = .{ .poly = 0x0589, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0001, .check = 0x007e, .residue = 0x0589 }; |
| 699 | |
| 700 | pub const Crc16DectR = Crc(u16, crc_16_dect_r); |
| 701 | |
| 702 | test "CRC-16/DECT-R" { |
| 703 | try testing.expectEqual(crc_16_dect_r.check, Crc16DectR.hash("123456789")); |
| 704 | |
| 705 | var c = Crc16DectR.init(); |
| 706 | c.update("1234"); |
| 707 | c.update("56789"); |
| 708 | try testing.expectEqual(crc_16_dect_r.check, c.final()); |
| 709 | } |
| 710 | |
| 711 | const crc_16_dect_x: Algorithm(u16) = .{ .poly = 0x0589, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x007f, .residue = 0x0000 }; |
| 712 | |
| 713 | pub const Crc16DectX = Crc(u16, crc_16_dect_x); |
| 714 | |
| 715 | test "CRC-16/DECT-X" { |
| 716 | try testing.expectEqual(crc_16_dect_x.check, Crc16DectX.hash("123456789")); |
| 717 | |
| 718 | var c = Crc16DectX.init(); |
| 719 | c.update("1234"); |
| 720 | c.update("56789"); |
| 721 | try testing.expectEqual(crc_16_dect_x.check, c.final()); |
| 722 | } |
| 723 | |
| 724 | const crc_16_dnp: Algorithm(u16) = .{ .poly = 0x3d65, .init = 0x0000, .refin = true, .refout = true, .xorout = 0xffff, .check = 0xea82, .residue = 0x66c5 }; |
| 725 | |
| 726 | pub const Crc16Dnp = Crc(u16, crc_16_dnp); |
| 727 | |
| 728 | test "CRC-16/DNP" { |
| 729 | try testing.expectEqual(crc_16_dnp.check, Crc16Dnp.hash("123456789")); |
| 730 | |
| 731 | var c = Crc16Dnp.init(); |
| 732 | c.update("1234"); |
| 733 | c.update("56789"); |
| 734 | try testing.expectEqual(crc_16_dnp.check, c.final()); |
| 735 | } |
| 736 | |
| 737 | const crc_16_en_13757: Algorithm(u16) = .{ .poly = 0x3d65, .init = 0x0000, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xc2b7, .residue = 0xa366 }; |
| 738 | |
| 739 | pub const Crc16En13757 = Crc(u16, crc_16_en_13757); |
| 740 | |
| 741 | test "CRC-16/EN-13757" { |
| 742 | try testing.expectEqual(crc_16_en_13757.check, Crc16En13757.hash("123456789")); |
| 743 | |
| 744 | var c = Crc16En13757.init(); |
| 745 | c.update("1234"); |
| 746 | c.update("56789"); |
| 747 | try testing.expectEqual(crc_16_en_13757.check, c.final()); |
| 748 | } |
| 749 | |
| 750 | const crc_16_genibus: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xd64e, .residue = 0x1d0f }; |
| 751 | |
| 752 | pub const Crc16Genibus = Crc(u16, crc_16_genibus); |
| 753 | |
| 754 | test "CRC-16/GENIBUS" { |
| 755 | try testing.expectEqual(crc_16_genibus.check, Crc16Genibus.hash("123456789")); |
| 756 | |
| 757 | var c = Crc16Genibus.init(); |
| 758 | c.update("1234"); |
| 759 | c.update("56789"); |
| 760 | try testing.expectEqual(crc_16_genibus.check, c.final()); |
| 761 | } |
| 762 | |
| 763 | const crc_16_gsm: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xce3c, .residue = 0x1d0f }; |
| 764 | |
| 765 | pub const Crc16Gsm = Crc(u16, crc_16_gsm); |
| 766 | |
| 767 | test "CRC-16/GSM" { |
| 768 | try testing.expectEqual(crc_16_gsm.check, Crc16Gsm.hash("123456789")); |
| 769 | |
| 770 | var c = Crc16Gsm.init(); |
| 771 | c.update("1234"); |
| 772 | c.update("56789"); |
| 773 | try testing.expectEqual(crc_16_gsm.check, c.final()); |
| 774 | } |
| 775 | |
| 776 | const crc_16_ibm_3740: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x29b1, .residue = 0x0000 }; |
| 777 | |
| 778 | pub const Crc16Ibm3740 = Crc(u16, crc_16_ibm_3740); |
| 779 | |
| 780 | test "CRC-16/IBM-3740" { |
| 781 | try testing.expectEqual(crc_16_ibm_3740.check, Crc16Ibm3740.hash("123456789")); |
| 782 | |
| 783 | var c = Crc16Ibm3740.init(); |
| 784 | c.update("1234"); |
| 785 | c.update("56789"); |
| 786 | try testing.expectEqual(crc_16_ibm_3740.check, c.final()); |
| 787 | } |
| 788 | |
| 789 | const crc_16_ibm_sdlc: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = true, .refout = true, .xorout = 0xffff, .check = 0x906e, .residue = 0xf0b8 }; |
| 790 | |
| 791 | pub const Crc16IbmSdlc = Crc(u16, crc_16_ibm_sdlc); |
| 792 | |
| 793 | test "CRC-16/IBM-SDLC" { |
| 794 | try testing.expectEqual(crc_16_ibm_sdlc.check, Crc16IbmSdlc.hash("123456789")); |
| 795 | |
| 796 | var c = Crc16IbmSdlc.init(); |
| 797 | c.update("1234"); |
| 798 | c.update("56789"); |
| 799 | try testing.expectEqual(crc_16_ibm_sdlc.check, c.final()); |
| 800 | } |
| 801 | |
| 802 | const crc_16_iso_iec_14443_3_a: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xc6c6, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xbf05, .residue = 0x0000 }; |
| 803 | |
| 804 | pub const Crc16IsoIec144433A = Crc(u16, crc_16_iso_iec_14443_3_a); |
| 805 | |
| 806 | test "CRC-16/ISO-IEC-14443-3-A" { |
| 807 | try testing.expectEqual(crc_16_iso_iec_14443_3_a.check, Crc16IsoIec144433A.hash("123456789")); |
| 808 | |
| 809 | var c = Crc16IsoIec144433A.init(); |
| 810 | c.update("1234"); |
| 811 | c.update("56789"); |
| 812 | try testing.expectEqual(crc_16_iso_iec_14443_3_a.check, c.final()); |
| 813 | } |
| 814 | |
| 815 | const crc_16_kermit: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x2189, .residue = 0x0000 }; |
| 816 | |
| 817 | pub const Crc16Kermit = Crc(u16, crc_16_kermit); |
| 818 | |
| 819 | test "CRC-16/KERMIT" { |
| 820 | try testing.expectEqual(crc_16_kermit.check, Crc16Kermit.hash("123456789")); |
| 821 | |
| 822 | var c = Crc16Kermit.init(); |
| 823 | c.update("1234"); |
| 824 | c.update("56789"); |
| 825 | try testing.expectEqual(crc_16_kermit.check, c.final()); |
| 826 | } |
| 827 | |
| 828 | const crc_16_lj1200: Algorithm(u16) = .{ .poly = 0x6f63, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xbdf4, .residue = 0x0000 }; |
| 829 | |
| 830 | pub const Crc16Lj1200 = Crc(u16, crc_16_lj1200); |
| 831 | |
| 832 | test "CRC-16/LJ1200" { |
| 833 | try testing.expectEqual(crc_16_lj1200.check, Crc16Lj1200.hash("123456789")); |
| 834 | |
| 835 | var c = Crc16Lj1200.init(); |
| 836 | c.update("1234"); |
| 837 | c.update("56789"); |
| 838 | try testing.expectEqual(crc_16_lj1200.check, c.final()); |
| 839 | } |
| 840 | |
| 841 | const crc_16_m17: Algorithm(u16) = .{ .poly = 0x5935, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x772b, .residue = 0x0000 }; |
| 842 | |
| 843 | pub const Crc16M17 = Crc(u16, crc_16_m17); |
| 844 | |
| 845 | test "CRC-16/M17" { |
| 846 | try testing.expectEqual(crc_16_m17.check, Crc16M17.hash("123456789")); |
| 847 | |
| 848 | var c = Crc16M17.init(); |
| 849 | c.update("1234"); |
| 850 | c.update("56789"); |
| 851 | try testing.expectEqual(crc_16_m17.check, c.final()); |
| 852 | } |
| 853 | |
| 854 | const crc_16_maxim_dow: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = true, .refout = true, .xorout = 0xffff, .check = 0x44c2, .residue = 0xb001 }; |
| 855 | |
| 856 | pub const Crc16MaximDow = Crc(u16, crc_16_maxim_dow); |
| 857 | |
| 858 | test "CRC-16/MAXIM-DOW" { |
| 859 | try testing.expectEqual(crc_16_maxim_dow.check, Crc16MaximDow.hash("123456789")); |
| 860 | |
| 861 | var c = Crc16MaximDow.init(); |
| 862 | c.update("1234"); |
| 863 | c.update("56789"); |
| 864 | try testing.expectEqual(crc_16_maxim_dow.check, c.final()); |
| 865 | } |
| 866 | |
| 867 | const crc_16_mcrf4xx: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x6f91, .residue = 0x0000 }; |
| 868 | |
| 869 | pub const Crc16Mcrf4xx = Crc(u16, crc_16_mcrf4xx); |
| 870 | |
| 871 | test "CRC-16/MCRF4XX" { |
| 872 | try testing.expectEqual(crc_16_mcrf4xx.check, Crc16Mcrf4xx.hash("123456789")); |
| 873 | |
| 874 | var c = Crc16Mcrf4xx.init(); |
| 875 | c.update("1234"); |
| 876 | c.update("56789"); |
| 877 | try testing.expectEqual(crc_16_mcrf4xx.check, c.final()); |
| 878 | } |
| 879 | |
| 880 | const crc_16_modbus: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x4b37, .residue = 0x0000 }; |
| 881 | |
| 882 | pub const Crc16Modbus = Crc(u16, crc_16_modbus); |
| 883 | |
| 884 | test "CRC-16/MODBUS" { |
| 885 | try testing.expectEqual(crc_16_modbus.check, Crc16Modbus.hash("123456789")); |
| 886 | |
| 887 | var c = Crc16Modbus.init(); |
| 888 | c.update("1234"); |
| 889 | c.update("56789"); |
| 890 | try testing.expectEqual(crc_16_modbus.check, c.final()); |
| 891 | } |
| 892 | |
| 893 | const crc_16_nrsc_5: Algorithm(u16) = .{ .poly = 0x080b, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xa066, .residue = 0x0000 }; |
| 894 | |
| 895 | pub const Crc16Nrsc5 = Crc(u16, crc_16_nrsc_5); |
| 896 | |
| 897 | test "CRC-16/NRSC-5" { |
| 898 | try testing.expectEqual(crc_16_nrsc_5.check, Crc16Nrsc5.hash("123456789")); |
| 899 | |
| 900 | var c = Crc16Nrsc5.init(); |
| 901 | c.update("1234"); |
| 902 | c.update("56789"); |
| 903 | try testing.expectEqual(crc_16_nrsc_5.check, c.final()); |
| 904 | } |
| 905 | |
| 906 | const crc_16_opensafety_a: Algorithm(u16) = .{ .poly = 0x5935, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x5d38, .residue = 0x0000 }; |
| 907 | |
| 908 | pub const Crc16OpensafetyA = Crc(u16, crc_16_opensafety_a); |
| 909 | |
| 910 | test "CRC-16/OPENSAFETY-A" { |
| 911 | try testing.expectEqual(crc_16_opensafety_a.check, Crc16OpensafetyA.hash("123456789")); |
| 912 | |
| 913 | var c = Crc16OpensafetyA.init(); |
| 914 | c.update("1234"); |
| 915 | c.update("56789"); |
| 916 | try testing.expectEqual(crc_16_opensafety_a.check, c.final()); |
| 917 | } |
| 918 | |
| 919 | const crc_16_opensafety_b: Algorithm(u16) = .{ .poly = 0x755b, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x20fe, .residue = 0x0000 }; |
| 920 | |
| 921 | pub const Crc16OpensafetyB = Crc(u16, crc_16_opensafety_b); |
| 922 | |
| 923 | test "CRC-16/OPENSAFETY-B" { |
| 924 | try testing.expectEqual(crc_16_opensafety_b.check, Crc16OpensafetyB.hash("123456789")); |
| 925 | |
| 926 | var c = Crc16OpensafetyB.init(); |
| 927 | c.update("1234"); |
| 928 | c.update("56789"); |
| 929 | try testing.expectEqual(crc_16_opensafety_b.check, c.final()); |
| 930 | } |
| 931 | |
| 932 | const crc_16_profibus: Algorithm(u16) = .{ .poly = 0x1dcf, .init = 0xffff, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xa819, .residue = 0xe394 }; |
| 933 | |
| 934 | pub const Crc16Profibus = Crc(u16, crc_16_profibus); |
| 935 | |
| 936 | test "CRC-16/PROFIBUS" { |
| 937 | try testing.expectEqual(crc_16_profibus.check, Crc16Profibus.hash("123456789")); |
| 938 | |
| 939 | var c = Crc16Profibus.init(); |
| 940 | c.update("1234"); |
| 941 | c.update("56789"); |
| 942 | try testing.expectEqual(crc_16_profibus.check, c.final()); |
| 943 | } |
| 944 | |
| 945 | const crc_16_riello: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xb2aa, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x63d0, .residue = 0x0000 }; |
| 946 | |
| 947 | pub const Crc16Riello = Crc(u16, crc_16_riello); |
| 948 | |
| 949 | test "CRC-16/RIELLO" { |
| 950 | try testing.expectEqual(crc_16_riello.check, Crc16Riello.hash("123456789")); |
| 951 | |
| 952 | var c = Crc16Riello.init(); |
| 953 | c.update("1234"); |
| 954 | c.update("56789"); |
| 955 | try testing.expectEqual(crc_16_riello.check, c.final()); |
| 956 | } |
| 957 | |
| 958 | const crc_16_spi_fujitsu: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x1d0f, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xe5cc, .residue = 0x0000 }; |
| 959 | |
| 960 | pub const Crc16SpiFujitsu = Crc(u16, crc_16_spi_fujitsu); |
| 961 | |
| 962 | test "CRC-16/SPI-FUJITSU" { |
| 963 | try testing.expectEqual(crc_16_spi_fujitsu.check, Crc16SpiFujitsu.hash("123456789")); |
| 964 | |
| 965 | var c = Crc16SpiFujitsu.init(); |
| 966 | c.update("1234"); |
| 967 | c.update("56789"); |
| 968 | try testing.expectEqual(crc_16_spi_fujitsu.check, c.final()); |
| 969 | } |
| 970 | |
| 971 | const crc_16_t10_dif: Algorithm(u16) = .{ .poly = 0x8bb7, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xd0db, .residue = 0x0000 }; |
| 972 | |
| 973 | pub const Crc16T10Dif = Crc(u16, crc_16_t10_dif); |
| 974 | |
| 975 | test "CRC-16/T10-DIF" { |
| 976 | try testing.expectEqual(crc_16_t10_dif.check, Crc16T10Dif.hash("123456789")); |
| 977 | |
| 978 | var c = Crc16T10Dif.init(); |
| 979 | c.update("1234"); |
| 980 | c.update("56789"); |
| 981 | try testing.expectEqual(crc_16_t10_dif.check, c.final()); |
| 982 | } |
| 983 | |
| 984 | const crc_16_teledisk: Algorithm(u16) = .{ .poly = 0xa097, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x0fb3, .residue = 0x0000 }; |
| 985 | |
| 986 | pub const Crc16Teledisk = Crc(u16, crc_16_teledisk); |
| 987 | |
| 988 | test "CRC-16/TELEDISK" { |
| 989 | try testing.expectEqual(crc_16_teledisk.check, Crc16Teledisk.hash("123456789")); |
| 990 | |
| 991 | var c = Crc16Teledisk.init(); |
| 992 | c.update("1234"); |
| 993 | c.update("56789"); |
| 994 | try testing.expectEqual(crc_16_teledisk.check, c.final()); |
| 995 | } |
| 996 | |
| 997 | const crc_16_tms37157: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x89ec, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x26b1, .residue = 0x0000 }; |
| 998 | |
| 999 | pub const Crc16Tms37157 = Crc(u16, crc_16_tms37157); |
| 1000 | |
| 1001 | test "CRC-16/TMS37157" { |
| 1002 | try testing.expectEqual(crc_16_tms37157.check, Crc16Tms37157.hash("123456789")); |
| 1003 | |
| 1004 | var c = Crc16Tms37157.init(); |
| 1005 | c.update("1234"); |
| 1006 | c.update("56789"); |
| 1007 | try testing.expectEqual(crc_16_tms37157.check, c.final()); |
| 1008 | } |
| 1009 | |
| 1010 | const crc_16_umts: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xfee8, .residue = 0x0000 }; |
| 1011 | |
| 1012 | pub const Crc16Umts = Crc(u16, crc_16_umts); |
| 1013 | |
| 1014 | test "CRC-16/UMTS" { |
| 1015 | try testing.expectEqual(crc_16_umts.check, Crc16Umts.hash("123456789")); |
| 1016 | |
| 1017 | var c = Crc16Umts.init(); |
| 1018 | c.update("1234"); |
| 1019 | c.update("56789"); |
| 1020 | try testing.expectEqual(crc_16_umts.check, c.final()); |
| 1021 | } |
| 1022 | |
| 1023 | const crc_16_usb: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = true, .refout = true, .xorout = 0xffff, .check = 0xb4c8, .residue = 0xb001 }; |
| 1024 | |
| 1025 | pub const Crc16Usb = Crc(u16, crc_16_usb); |
| 1026 | |
| 1027 | test "CRC-16/USB" { |
| 1028 | try testing.expectEqual(crc_16_usb.check, Crc16Usb.hash("123456789")); |
| 1029 | |
| 1030 | var c = Crc16Usb.init(); |
| 1031 | c.update("1234"); |
| 1032 | c.update("56789"); |
| 1033 | try testing.expectEqual(crc_16_usb.check, c.final()); |
| 1034 | } |
| 1035 | |
| 1036 | const crc_16_xmodem: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x31c3, .residue = 0x0000 }; |
| 1037 | |
| 1038 | pub const Crc16Xmodem = Crc(u16, crc_16_xmodem); |
| 1039 | |
| 1040 | test "CRC-16/XMODEM" { |
| 1041 | try testing.expectEqual(crc_16_xmodem.check, Crc16Xmodem.hash("123456789")); |
| 1042 | |
| 1043 | var c = Crc16Xmodem.init(); |
| 1044 | c.update("1234"); |
| 1045 | c.update("56789"); |
| 1046 | try testing.expectEqual(crc_16_xmodem.check, c.final()); |
| 1047 | } |
| 1048 | |
| 1049 | const crc_17_can_fd: Algorithm(u17) = .{ .poly = 0x1685b, .init = 0x00000, .refin = false, .refout = false, .xorout = 0x00000, .check = 0x04f03, .residue = 0x00000 }; |
| 1050 | |
| 1051 | pub const Crc17CanFd = Crc(u17, crc_17_can_fd); |
| 1052 | |
| 1053 | test "CRC-17/CAN-FD" { |
| 1054 | try testing.expectEqual(crc_17_can_fd.check, Crc17CanFd.hash("123456789")); |
| 1055 | |
| 1056 | var c = Crc17CanFd.init(); |
| 1057 | c.update("1234"); |
| 1058 | c.update("56789"); |
| 1059 | try testing.expectEqual(crc_17_can_fd.check, c.final()); |
| 1060 | } |
| 1061 | |
| 1062 | const crc_21_can_fd: Algorithm(u21) = .{ .poly = 0x102899, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x0ed841, .residue = 0x000000 }; |
| 1063 | |
| 1064 | pub const Crc21CanFd = Crc(u21, crc_21_can_fd); |
| 1065 | |
| 1066 | test "CRC-21/CAN-FD" { |
| 1067 | try testing.expectEqual(crc_21_can_fd.check, Crc21CanFd.hash("123456789")); |
| 1068 | |
| 1069 | var c = Crc21CanFd.init(); |
| 1070 | c.update("1234"); |
| 1071 | c.update("56789"); |
| 1072 | try testing.expectEqual(crc_21_can_fd.check, c.final()); |
| 1073 | } |
| 1074 | |
| 1075 | const crc_24_ble: Algorithm(u24) = .{ .poly = 0x00065b, .init = 0x555555, .refin = true, .refout = true, .xorout = 0x000000, .check = 0xc25a56, .residue = 0x000000 }; |
| 1076 | |
| 1077 | pub const Crc24Ble = Crc(u24, crc_24_ble); |
| 1078 | |
| 1079 | test "CRC-24/BLE" { |
| 1080 | try testing.expectEqual(crc_24_ble.check, Crc24Ble.hash("123456789")); |
| 1081 | |
| 1082 | var c = Crc24Ble.init(); |
| 1083 | c.update("1234"); |
| 1084 | c.update("56789"); |
| 1085 | try testing.expectEqual(crc_24_ble.check, c.final()); |
| 1086 | } |
| 1087 | |
| 1088 | const crc_24_flexray_a: Algorithm(u24) = .{ .poly = 0x5d6dcb, .init = 0xfedcba, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x7979bd, .residue = 0x000000 }; |
| 1089 | |
| 1090 | pub const Crc24FlexrayA = Crc(u24, crc_24_flexray_a); |
| 1091 | |
| 1092 | test "CRC-24/FLEXRAY-A" { |
| 1093 | try testing.expectEqual(crc_24_flexray_a.check, Crc24FlexrayA.hash("123456789")); |
| 1094 | |
| 1095 | var c = Crc24FlexrayA.init(); |
| 1096 | c.update("1234"); |
| 1097 | c.update("56789"); |
| 1098 | try testing.expectEqual(crc_24_flexray_a.check, c.final()); |
| 1099 | } |
| 1100 | |
| 1101 | const crc_24_flexray_b: Algorithm(u24) = .{ .poly = 0x5d6dcb, .init = 0xabcdef, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x1f23b8, .residue = 0x000000 }; |
| 1102 | |
| 1103 | pub const Crc24FlexrayB = Crc(u24, crc_24_flexray_b); |
| 1104 | |
| 1105 | test "CRC-24/FLEXRAY-B" { |
| 1106 | try testing.expectEqual(crc_24_flexray_b.check, Crc24FlexrayB.hash("123456789")); |
| 1107 | |
| 1108 | var c = Crc24FlexrayB.init(); |
| 1109 | c.update("1234"); |
| 1110 | c.update("56789"); |
| 1111 | try testing.expectEqual(crc_24_flexray_b.check, c.final()); |
| 1112 | } |
| 1113 | |
| 1114 | const crc_24_interlaken: Algorithm(u24) = .{ .poly = 0x328b63, .init = 0xffffff, .refin = false, .refout = false, .xorout = 0xffffff, .check = 0xb4f3e6, .residue = 0x144e63 }; |
| 1115 | |
| 1116 | pub const Crc24Interlaken = Crc(u24, crc_24_interlaken); |
| 1117 | |
| 1118 | test "CRC-24/INTERLAKEN" { |
| 1119 | try testing.expectEqual(crc_24_interlaken.check, Crc24Interlaken.hash("123456789")); |
| 1120 | |
| 1121 | var c = Crc24Interlaken.init(); |
| 1122 | c.update("1234"); |
| 1123 | c.update("56789"); |
| 1124 | try testing.expectEqual(crc_24_interlaken.check, c.final()); |
| 1125 | } |
| 1126 | |
| 1127 | const crc_24_lte_a: Algorithm(u24) = .{ .poly = 0x864cfb, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0xcde703, .residue = 0x000000 }; |
| 1128 | |
| 1129 | pub const Crc24LteA = Crc(u24, crc_24_lte_a); |
| 1130 | |
| 1131 | test "CRC-24/LTE-A" { |
| 1132 | try testing.expectEqual(crc_24_lte_a.check, Crc24LteA.hash("123456789")); |
| 1133 | |
| 1134 | var c = Crc24LteA.init(); |
| 1135 | c.update("1234"); |
| 1136 | c.update("56789"); |
| 1137 | try testing.expectEqual(crc_24_lte_a.check, c.final()); |
| 1138 | } |
| 1139 | |
| 1140 | const crc_24_lte_b: Algorithm(u24) = .{ .poly = 0x800063, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x23ef52, .residue = 0x000000 }; |
| 1141 | |
| 1142 | pub const Crc24LteB = Crc(u24, crc_24_lte_b); |
| 1143 | |
| 1144 | test "CRC-24/LTE-B" { |
| 1145 | try testing.expectEqual(crc_24_lte_b.check, Crc24LteB.hash("123456789")); |
| 1146 | |
| 1147 | var c = Crc24LteB.init(); |
| 1148 | c.update("1234"); |
| 1149 | c.update("56789"); |
| 1150 | try testing.expectEqual(crc_24_lte_b.check, c.final()); |
| 1151 | } |
| 1152 | |
| 1153 | const crc_24_openpgp: Algorithm(u24) = .{ .poly = 0x864cfb, .init = 0xb704ce, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x21cf02, .residue = 0x000000 }; |
| 1154 | |
| 1155 | pub const Crc24Openpgp = Crc(u24, crc_24_openpgp); |
| 1156 | |
| 1157 | test "CRC-24/OPENPGP" { |
| 1158 | try testing.expectEqual(crc_24_openpgp.check, Crc24Openpgp.hash("123456789")); |
| 1159 | |
| 1160 | var c = Crc24Openpgp.init(); |
| 1161 | c.update("1234"); |
| 1162 | c.update("56789"); |
| 1163 | try testing.expectEqual(crc_24_openpgp.check, c.final()); |
| 1164 | } |
| 1165 | |
| 1166 | const crc_24_os_9: Algorithm(u24) = .{ .poly = 0x800063, .init = 0xffffff, .refin = false, .refout = false, .xorout = 0xffffff, .check = 0x200fa5, .residue = 0x800fe3 }; |
| 1167 | |
| 1168 | pub const Crc24Os9 = Crc(u24, crc_24_os_9); |
| 1169 | |
| 1170 | test "CRC-24/OS-9" { |
| 1171 | try testing.expectEqual(crc_24_os_9.check, Crc24Os9.hash("123456789")); |
| 1172 | |
| 1173 | var c = Crc24Os9.init(); |
| 1174 | c.update("1234"); |
| 1175 | c.update("56789"); |
| 1176 | try testing.expectEqual(crc_24_os_9.check, c.final()); |
| 1177 | } |
| 1178 | |
| 1179 | const crc_30_cdma: Algorithm(u30) = .{ .poly = 0x2030b9c7, .init = 0x3fffffff, .refin = false, .refout = false, .xorout = 0x3fffffff, .check = 0x04c34abf, .residue = 0x34efa55a }; |
| 1180 | |
| 1181 | pub const Crc30Cdma = Crc(u30, crc_30_cdma); |
| 1182 | |
| 1183 | test "CRC-30/CDMA" { |
| 1184 | try testing.expectEqual(crc_30_cdma.check, Crc30Cdma.hash("123456789")); |
| 1185 | |
| 1186 | var c = Crc30Cdma.init(); |
| 1187 | c.update("1234"); |
| 1188 | c.update("56789"); |
| 1189 | try testing.expectEqual(crc_30_cdma.check, c.final()); |
| 1190 | } |
| 1191 | |
| 1192 | const crc_31_philips: Algorithm(u31) = .{ .poly = 0x04c11db7, .init = 0x7fffffff, .refin = false, .refout = false, .xorout = 0x7fffffff, .check = 0x0ce9e46c, .residue = 0x4eaf26f1 }; |
| 1193 | |
| 1194 | pub const Crc31Philips = Crc(u31, crc_31_philips); |
| 1195 | |
| 1196 | test "CRC-31/PHILIPS" { |
| 1197 | try testing.expectEqual(crc_31_philips.check, Crc31Philips.hash("123456789")); |
| 1198 | |
| 1199 | var c = Crc31Philips.init(); |
| 1200 | c.update("1234"); |
| 1201 | c.update("56789"); |
| 1202 | try testing.expectEqual(crc_31_philips.check, c.final()); |
| 1203 | } |
| 1204 | |
| 1205 | const crc_32_aixm: Algorithm(u32) = .{ .poly = 0x814141ab, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0x3010bf7f, .residue = 0x00000000 }; |
| 1206 | |
| 1207 | pub const Crc32Aixm = Crc(u32, crc_32_aixm); |
| 1208 | |
| 1209 | test "CRC-32/AIXM" { |
| 1210 | try testing.expectEqual(crc_32_aixm.check, Crc32Aixm.hash("123456789")); |
| 1211 | |
| 1212 | var c = Crc32Aixm.init(); |
| 1213 | c.update("1234"); |
| 1214 | c.update("56789"); |
| 1215 | try testing.expectEqual(crc_32_aixm.check, c.final()); |
| 1216 | } |
| 1217 | |
| 1218 | const crc_32_autosar: Algorithm(u32) = .{ .poly = 0xf4acfb13, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0x1697d06a, .residue = 0x904cddbf }; |
| 1219 | |
| 1220 | pub const Crc32Autosar = Crc(u32, crc_32_autosar); |
| 1221 | |
| 1222 | test "CRC-32/AUTOSAR" { |
| 1223 | try testing.expectEqual(crc_32_autosar.check, Crc32Autosar.hash("123456789")); |
| 1224 | |
| 1225 | var c = Crc32Autosar.init(); |
| 1226 | c.update("1234"); |
| 1227 | c.update("56789"); |
| 1228 | try testing.expectEqual(crc_32_autosar.check, c.final()); |
| 1229 | } |
| 1230 | |
| 1231 | const crc_32_base91_d: Algorithm(u32) = .{ .poly = 0xa833982b, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0x87315576, .residue = 0x45270551 }; |
| 1232 | |
| 1233 | pub const Crc32Base91D = Crc(u32, crc_32_base91_d); |
| 1234 | |
| 1235 | test "CRC-32/BASE91-D" { |
| 1236 | try testing.expectEqual(crc_32_base91_d.check, Crc32Base91D.hash("123456789")); |
| 1237 | |
| 1238 | var c = Crc32Base91D.init(); |
| 1239 | c.update("1234"); |
| 1240 | c.update("56789"); |
| 1241 | try testing.expectEqual(crc_32_base91_d.check, c.final()); |
| 1242 | } |
| 1243 | |
| 1244 | const crc_32_bzip2: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = false, .refout = false, .xorout = 0xffffffff, .check = 0xfc891918, .residue = 0xc704dd7b }; |
| 1245 | |
| 1246 | pub const Crc32Bzip2 = Crc(u32, crc_32_bzip2); |
| 1247 | |
| 1248 | test "CRC-32/BZIP2" { |
| 1249 | try testing.expectEqual(crc_32_bzip2.check, Crc32Bzip2.hash("123456789")); |
| 1250 | |
| 1251 | var c = Crc32Bzip2.init(); |
| 1252 | c.update("1234"); |
| 1253 | c.update("56789"); |
| 1254 | try testing.expectEqual(crc_32_bzip2.check, c.final()); |
| 1255 | } |
| 1256 | |
| 1257 | const crc_32_cd_rom_edc: Algorithm(u32) = .{ .poly = 0x8001801b, .init = 0x00000000, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0x6ec2edc4, .residue = 0x00000000 }; |
| 1258 | |
| 1259 | pub const Crc32CdRomEdc = Crc(u32, crc_32_cd_rom_edc); |
| 1260 | |
| 1261 | test "CRC-32/CD-ROM-EDC" { |
| 1262 | try testing.expectEqual(crc_32_cd_rom_edc.check, Crc32CdRomEdc.hash("123456789")); |
| 1263 | |
| 1264 | var c = Crc32CdRomEdc.init(); |
| 1265 | c.update("1234"); |
| 1266 | c.update("56789"); |
| 1267 | try testing.expectEqual(crc_32_cd_rom_edc.check, c.final()); |
| 1268 | } |
| 1269 | |
| 1270 | const crc_32_cksum: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0xffffffff, .check = 0x765e7680, .residue = 0xc704dd7b }; |
| 1271 | |
| 1272 | pub const Crc32Cksum = Crc(u32, crc_32_cksum); |
| 1273 | |
| 1274 | test "CRC-32/CKSUM" { |
| 1275 | try testing.expectEqual(crc_32_cksum.check, Crc32Cksum.hash("123456789")); |
| 1276 | |
| 1277 | var c = Crc32Cksum.init(); |
| 1278 | c.update("1234"); |
| 1279 | c.update("56789"); |
| 1280 | try testing.expectEqual(crc_32_cksum.check, c.final()); |
| 1281 | } |
| 1282 | |
| 1283 | const crc_32_iscsi: Algorithm(u32) = .{ .poly = 0x1edc6f41, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0xe3069283, .residue = 0xb798b438 }; |
| 1284 | |
| 1285 | pub const Crc32Iscsi = Crc(u32, crc_32_iscsi); |
| 1286 | |
| 1287 | test "CRC-32/ISCSI" { |
| 1288 | try testing.expectEqual(crc_32_iscsi.check, Crc32Iscsi.hash("123456789")); |
| 1289 | |
| 1290 | var c = Crc32Iscsi.init(); |
| 1291 | c.update("1234"); |
| 1292 | c.update("56789"); |
| 1293 | try testing.expectEqual(crc_32_iscsi.check, c.final()); |
| 1294 | } |
| 1295 | |
| 1296 | const crc_32_iso_hdlc: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0xcbf43926, .residue = 0xdebb20e3 }; |
| 1297 | |
| 1298 | pub const Crc32IsoHdlc = Crc(u32, crc_32_iso_hdlc); |
| 1299 | |
| 1300 | test "CRC-32/ISO-HDLC" { |
| 1301 | try testing.expectEqual(crc_32_iso_hdlc.check, Crc32IsoHdlc.hash("123456789")); |
| 1302 | |
| 1303 | var c = Crc32IsoHdlc.init(); |
| 1304 | c.update("1234"); |
| 1305 | c.update("56789"); |
| 1306 | try testing.expectEqual(crc_32_iso_hdlc.check, c.final()); |
| 1307 | } |
| 1308 | |
| 1309 | const crc_32_jamcrc: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0x340bc6d9, .residue = 0x00000000 }; |
| 1310 | |
| 1311 | pub const Crc32Jamcrc = Crc(u32, crc_32_jamcrc); |
| 1312 | |
| 1313 | test "CRC-32/JAMCRC" { |
| 1314 | try testing.expectEqual(crc_32_jamcrc.check, Crc32Jamcrc.hash("123456789")); |
| 1315 | |
| 1316 | var c = Crc32Jamcrc.init(); |
| 1317 | c.update("1234"); |
| 1318 | c.update("56789"); |
| 1319 | try testing.expectEqual(crc_32_jamcrc.check, c.final()); |
| 1320 | } |
| 1321 | |
| 1322 | const crc_32_mef: Algorithm(u32) = .{ .poly = 0x741b8cd7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0xd2c22f51, .residue = 0x00000000 }; |
| 1323 | |
| 1324 | pub const Crc32Mef = Crc(u32, crc_32_mef); |
| 1325 | |
| 1326 | test "CRC-32/MEF" { |
| 1327 | try testing.expectEqual(crc_32_mef.check, Crc32Mef.hash("123456789")); |
| 1328 | |
| 1329 | var c = Crc32Mef.init(); |
| 1330 | c.update("1234"); |
| 1331 | c.update("56789"); |
| 1332 | try testing.expectEqual(crc_32_mef.check, c.final()); |
| 1333 | } |
| 1334 | |
| 1335 | const crc_32_mpeg_2: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0x0376e6e7, .residue = 0x00000000 }; |
| 1336 | |
| 1337 | pub const Crc32Mpeg2 = Crc(u32, crc_32_mpeg_2); |
| 1338 | |
| 1339 | test "CRC-32/MPEG-2" { |
| 1340 | try testing.expectEqual(crc_32_mpeg_2.check, Crc32Mpeg2.hash("123456789")); |
| 1341 | |
| 1342 | var c = Crc32Mpeg2.init(); |
| 1343 | c.update("1234"); |
| 1344 | c.update("56789"); |
| 1345 | try testing.expectEqual(crc_32_mpeg_2.check, c.final()); |
| 1346 | } |
| 1347 | |
| 1348 | const crc_32_xfer: Algorithm(u32) = .{ .poly = 0x000000af, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0xbd0be338, .residue = 0x00000000 }; |
| 1349 | |
| 1350 | pub const Crc32Xfer = Crc(u32, crc_32_xfer); |
| 1351 | |
| 1352 | test "CRC-32/XFER" { |
| 1353 | try testing.expectEqual(crc_32_xfer.check, Crc32Xfer.hash("123456789")); |
| 1354 | |
| 1355 | var c = Crc32Xfer.init(); |
| 1356 | c.update("1234"); |
| 1357 | c.update("56789"); |
| 1358 | try testing.expectEqual(crc_32_xfer.check, c.final()); |
| 1359 | } |
| 1360 | |
| 1361 | const crc_40_gsm: Algorithm(u40) = .{ .poly = 0x0004820009, .init = 0x0000000000, .refin = false, .refout = false, .xorout = 0xffffffffff, .check = 0xd4164fc646, .residue = 0xc4ff8071ff }; |
| 1362 | |
| 1363 | pub const Crc40Gsm = Crc(u40, crc_40_gsm); |
| 1364 | |
| 1365 | test "CRC-40/GSM" { |
| 1366 | try testing.expectEqual(crc_40_gsm.check, Crc40Gsm.hash("123456789")); |
| 1367 | |
| 1368 | var c = Crc40Gsm.init(); |
| 1369 | c.update("1234"); |
| 1370 | c.update("56789"); |
| 1371 | try testing.expectEqual(crc_40_gsm.check, c.final()); |
| 1372 | } |
| 1373 | |
| 1374 | const crc_64_ecma_182: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0x0000000000000000, .refin = false, .refout = false, .xorout = 0x0000000000000000, .check = 0x6c40df5f0b497347, .residue = 0x0000000000000000 }; |
| 1375 | |
| 1376 | pub const Crc64Ecma182 = Crc(u64, crc_64_ecma_182); |
| 1377 | |
| 1378 | test "CRC-64/ECMA-182" { |
| 1379 | try testing.expectEqual(crc_64_ecma_182.check, Crc64Ecma182.hash("123456789")); |
| 1380 | |
| 1381 | var c = Crc64Ecma182.init(); |
| 1382 | c.update("1234"); |
| 1383 | c.update("56789"); |
| 1384 | try testing.expectEqual(crc_64_ecma_182.check, c.final()); |
| 1385 | } |
| 1386 | |
| 1387 | const crc_64_go_iso: Algorithm(u64) = .{ .poly = 0x000000000000001b, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0xffffffffffffffff, .check = 0xb90956c775a41001, .residue = 0x5300000000000000 }; |
| 1388 | |
| 1389 | pub const Crc64GoIso = Crc(u64, crc_64_go_iso); |
| 1390 | |
| 1391 | test "CRC-64/GO-ISO" { |
| 1392 | try testing.expectEqual(crc_64_go_iso.check, Crc64GoIso.hash("123456789")); |
| 1393 | |
| 1394 | var c = Crc64GoIso.init(); |
| 1395 | c.update("1234"); |
| 1396 | c.update("56789"); |
| 1397 | try testing.expectEqual(crc_64_go_iso.check, c.final()); |
| 1398 | } |
| 1399 | |
| 1400 | const crc_64_ms: Algorithm(u64) = .{ .poly = 0x259c84cba6426349, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0x0000000000000000, .check = 0x75d4b74f024eceea, .residue = 0x0000000000000000 }; |
| 1401 | |
| 1402 | pub const Crc64Ms = Crc(u64, crc_64_ms); |
| 1403 | |
| 1404 | test "CRC-64/MS" { |
| 1405 | try testing.expectEqual(crc_64_ms.check, Crc64Ms.hash("123456789")); |
| 1406 | |
| 1407 | var c = Crc64Ms.init(); |
| 1408 | c.update("1234"); |
| 1409 | c.update("56789"); |
| 1410 | try testing.expectEqual(crc_64_ms.check, c.final()); |
| 1411 | } |
| 1412 | |
| 1413 | const crc_64_redis: Algorithm(u64) = .{ .poly = 0xad93d23594c935a9, .init = 0x0000000000000000, .refin = true, .refout = true, .xorout = 0x0000000000000000, .check = 0xe9c6d914c4b8d9ca, .residue = 0x0000000000000000 }; |
| 1414 | |
| 1415 | pub const Crc64Redis = Crc(u64, crc_64_redis); |
| 1416 | |
| 1417 | test "CRC-64/REDIS" { |
| 1418 | try testing.expectEqual(crc_64_redis.check, Crc64Redis.hash("123456789")); |
| 1419 | |
| 1420 | var c = Crc64Redis.init(); |
| 1421 | c.update("1234"); |
| 1422 | c.update("56789"); |
| 1423 | try testing.expectEqual(crc_64_redis.check, c.final()); |
| 1424 | } |
| 1425 | |
| 1426 | const crc_64_we: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0xffffffffffffffff, .refin = false, .refout = false, .xorout = 0xffffffffffffffff, .check = 0x62ec59e3f1a4f00a, .residue = 0xfcacbebd5931a992 }; |
| 1427 | |
| 1428 | pub const Crc64We = Crc(u64, crc_64_we); |
| 1429 | |
| 1430 | test "CRC-64/WE" { |
| 1431 | try testing.expectEqual(crc_64_we.check, Crc64We.hash("123456789")); |
| 1432 | |
| 1433 | var c = Crc64We.init(); |
| 1434 | c.update("1234"); |
| 1435 | c.update("56789"); |
| 1436 | try testing.expectEqual(crc_64_we.check, c.final()); |
| 1437 | } |
| 1438 | |
| 1439 | const crc_64_xz: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0xffffffffffffffff, .check = 0x995dc9bbdf1939fa, .residue = 0x49958c9abd7d353f }; |
| 1440 | |
| 1441 | pub const Crc64Xz = Crc(u64, crc_64_xz); |
| 1442 | |
| 1443 | test "CRC-64/XZ" { |
| 1444 | try testing.expectEqual(crc_64_xz.check, Crc64Xz.hash("123456789")); |
| 1445 | |
| 1446 | var c = Crc64Xz.init(); |
| 1447 | c.update("1234"); |
| 1448 | c.update("56789"); |
| 1449 | try testing.expectEqual(crc_64_xz.check, c.final()); |
| 1450 | } |
| 1451 | |
| 1452 | const crc_82_darc: Algorithm(u82) = .{ .poly = 0x0308c0111011401440411, .init = 0x000000000000000000000, .refin = true, .refout = true, .xorout = 0x000000000000000000000, .check = 0x09ea83f625023801fd612, .residue = 0x000000000000000000000 }; |
| 1453 | |
| 1454 | pub const Crc82Darc = Crc(u82, crc_82_darc); |
| 1455 | |
| 1456 | test "CRC-82/DARC" { |
| 1457 | try testing.expectEqual(crc_82_darc.check, Crc82Darc.hash("123456789")); |
| 1458 | |
| 1459 | var c = Crc82Darc.init(); |
| 1460 | c.update("1234"); |
| 1461 | c.update("56789"); |
| 1462 | try testing.expectEqual(crc_82_darc.check, c.final()); |
| 1463 | } |